@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | $this->middleware(['auth', 'web', '2fa'])->except('api', 'contact', 'showContactForm', 'callback', 'btcPayCallback', 'getNzb', 'terms', 'privacyPolicy', 'capabilities', 'movie', 'apiSearch', 'tv', 'details', 'failed', 'showRssDesc', 'fullFeedRss', 'categoryFeedRss', 'cartRss', 'myMoviesRss', 'myShowsRss', 'trendingMoviesRss', 'trendingShowsRss', 'release', 'reset', 'showLinkRequestForm'); |
| 53 | 53 | |
| 54 | 54 | // Load settings as collection with caching (5 minutes) |
| 55 | - $this->settings = Cache::remember('site_settings', 300, function () { |
|
| 55 | + $this->settings = Cache::remember('site_settings', 300, function() { |
|
| 56 | 56 | return Settings::query()->pluck('value', 'name'); |
| 57 | 57 | }); |
| 58 | 58 | |
@@ -62,14 +62,14 @@ discard block |
||
| 62 | 62 | ]; |
| 63 | 63 | |
| 64 | 64 | // Then add the converted settings array as 'site' with caching |
| 65 | - $this->viewData['site'] = Cache::remember('site_settings_converted', 300, function () { |
|
| 66 | - return $this->settings->map(function ($value) { |
|
| 65 | + $this->viewData['site'] = Cache::remember('site_settings_converted', 300, function() { |
|
| 66 | + return $this->settings->map(function($value) { |
|
| 67 | 67 | return Settings::convertValue($value); |
| 68 | 68 | })->all(); |
| 69 | 69 | }); |
| 70 | 70 | |
| 71 | 71 | // Initialize userdata property for controllers that need it |
| 72 | - $this->middleware(function ($request, $next) { |
|
| 72 | + $this->middleware(function($request, $next) { |
|
| 73 | 73 | if (Auth::check()) { |
| 74 | 74 | $userId = Auth::id(); |
| 75 | 75 | $this->userdata = User::find($userId); |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | $this->setAdminPrefs(); |
| 28 | 28 | |
| 29 | 29 | // Cache user statistics for 2 minutes |
| 30 | - $userStats = \Illuminate\Support\Facades\Cache::remember('admin_user_stats', 120, function () { |
|
| 30 | + $userStats = \Illuminate\Support\Facades\Cache::remember('admin_user_stats', 120, function() { |
|
| 31 | 31 | return [ |
| 32 | 32 | 'users_by_role' => $this->userStatsService->getUsersByRole(), |
| 33 | 33 | 'downloads_per_hour' => $this->userStatsService->getDownloadsPerHour(168), // Last 7 days in hours |
@@ -54,12 +54,12 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | protected function getRecentUserActivity(): array |
| 56 | 56 | { |
| 57 | - return \Illuminate\Support\Facades\Cache::remember('admin_recent_activity', 60, function () { |
|
| 57 | + return \Illuminate\Support\Facades\Cache::remember('admin_recent_activity', 60, function() { |
|
| 58 | 58 | $activities = \App\Models\UserActivity::orderBy('created_at', 'desc') |
| 59 | 59 | ->limit(10) |
| 60 | 60 | ->get(); |
| 61 | 61 | |
| 62 | - return $activities->map(function ($activity) { |
|
| 62 | + return $activities->map(function($activity) { |
|
| 63 | 63 | return (object) [ |
| 64 | 64 | 'type' => $activity->activity_type, |
| 65 | 65 | 'message' => $activity->description, |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | return response()->json([ |
| 84 | 84 | 'success' => true, |
| 85 | - 'activities' => array_map(function ($activity) { |
|
| 85 | + 'activities' => array_map(function($activity) { |
|
| 86 | 86 | return [ |
| 87 | 87 | 'type' => $activity->type, |
| 88 | 88 | 'message' => $activity->message, |
@@ -104,36 +104,36 @@ discard block |
||
| 104 | 104 | $today = now()->format('Y-m-d'); |
| 105 | 105 | |
| 106 | 106 | // Cache total releases count for 5 minutes (expensive query on large tables) |
| 107 | - $releasesCount = \Illuminate\Support\Facades\Cache::remember('admin_stats_releases_count', 300, function () { |
|
| 107 | + $releasesCount = \Illuminate\Support\Facades\Cache::remember('admin_stats_releases_count', 300, function() { |
|
| 108 | 108 | return \App\Models\Release::count(); |
| 109 | 109 | }); |
| 110 | 110 | |
| 111 | 111 | // Cache users count for 5 minutes |
| 112 | - $usersCount = \Illuminate\Support\Facades\Cache::remember('admin_stats_users_count', 300, function () { |
|
| 112 | + $usersCount = \Illuminate\Support\Facades\Cache::remember('admin_stats_users_count', 300, function() { |
|
| 113 | 113 | return \App\Models\User::whereNull('deleted_at')->count(); |
| 114 | 114 | }); |
| 115 | 115 | |
| 116 | 116 | // Cache groups count for 10 minutes (rarely changes) |
| 117 | - $groupsCount = \Illuminate\Support\Facades\Cache::remember('admin_stats_groups_count', 600, function () { |
|
| 117 | + $groupsCount = \Illuminate\Support\Facades\Cache::remember('admin_stats_groups_count', 600, function() { |
|
| 118 | 118 | return \App\Models\UsenetGroup::count(); |
| 119 | 119 | }); |
| 120 | 120 | |
| 121 | 121 | // Cache active groups count for 10 minutes |
| 122 | - $activeGroupsCount = \Illuminate\Support\Facades\Cache::remember('admin_stats_active_groups_count', 600, function () { |
|
| 122 | + $activeGroupsCount = \Illuminate\Support\Facades\Cache::remember('admin_stats_active_groups_count', 600, function() { |
|
| 123 | 123 | return \App\Models\UsenetGroup::where('active', 1)->count(); |
| 124 | 124 | }); |
| 125 | 125 | |
| 126 | 126 | // Cache failed count for 5 minutes |
| 127 | - $failedCount = \Illuminate\Support\Facades\Cache::remember('admin_stats_failed_count', 300, function () { |
|
| 127 | + $failedCount = \Illuminate\Support\Facades\Cache::remember('admin_stats_failed_count', 300, function() { |
|
| 128 | 128 | return \App\Models\DnzbFailure::count(); |
| 129 | 129 | }); |
| 130 | 130 | |
| 131 | 131 | // Today's counts can be cached for 1 minute since they change frequently |
| 132 | - $releasesToday = \Illuminate\Support\Facades\Cache::remember('admin_stats_releases_today_'.$today, 60, function () use ($today) { |
|
| 132 | + $releasesToday = \Illuminate\Support\Facades\Cache::remember('admin_stats_releases_today_'.$today, 60, function() use ($today) { |
|
| 133 | 133 | return \App\Models\Release::whereRaw('DATE(adddate) = ?', [$today])->count(); |
| 134 | 134 | }); |
| 135 | 135 | |
| 136 | - $usersToday = \Illuminate\Support\Facades\Cache::remember('admin_stats_users_today_'.$today, 60, function () use ($today) { |
|
| 136 | + $usersToday = \Illuminate\Support\Facades\Cache::remember('admin_stats_users_today_'.$today, 60, function() use ($today) { |
|
| 137 | 137 | return \App\Models\User::whereRaw('DATE(created_at) = ?', [$today])->count(); |
| 138 | 138 | }); |
| 139 | 139 | |
@@ -174,37 +174,37 @@ discard block |
||
| 174 | 174 | protected function getSystemMetrics(): array |
| 175 | 175 | { |
| 176 | 176 | // Cache CPU info for 1 hour (doesn't change) |
| 177 | - $cpuInfo = \Illuminate\Support\Facades\Cache::remember('admin_cpu_info', 3600, function () { |
|
| 177 | + $cpuInfo = \Illuminate\Support\Facades\Cache::remember('admin_cpu_info', 3600, function() { |
|
| 178 | 178 | return $this->getCpuInfo(); |
| 179 | 179 | }); |
| 180 | 180 | |
| 181 | 181 | // Cache current metrics for 30 seconds |
| 182 | - $cpuUsage = \Illuminate\Support\Facades\Cache::remember('admin_cpu_usage', 30, function () { |
|
| 182 | + $cpuUsage = \Illuminate\Support\Facades\Cache::remember('admin_cpu_usage', 30, function() { |
|
| 183 | 183 | return $this->getCpuUsage(); |
| 184 | 184 | }); |
| 185 | 185 | |
| 186 | - $ramUsage = \Illuminate\Support\Facades\Cache::remember('admin_ram_usage', 30, function () { |
|
| 186 | + $ramUsage = \Illuminate\Support\Facades\Cache::remember('admin_ram_usage', 30, function() { |
|
| 187 | 187 | return $this->getRamUsage(); |
| 188 | 188 | }); |
| 189 | 189 | |
| 190 | - $loadAverage = \Illuminate\Support\Facades\Cache::remember('admin_load_average', 30, function () { |
|
| 190 | + $loadAverage = \Illuminate\Support\Facades\Cache::remember('admin_load_average', 30, function() { |
|
| 191 | 191 | return $this->getLoadAverage(); |
| 192 | 192 | }); |
| 193 | 193 | |
| 194 | 194 | // Cache historical data for 5 minutes (from database) |
| 195 | - $cpuHistory24h = \Illuminate\Support\Facades\Cache::remember('admin_cpu_history_24h', 300, function () { |
|
| 195 | + $cpuHistory24h = \Illuminate\Support\Facades\Cache::remember('admin_cpu_history_24h', 300, function() { |
|
| 196 | 196 | return $this->systemMetricsService->getHourlyMetrics('cpu', 24); |
| 197 | 197 | }); |
| 198 | 198 | |
| 199 | - $cpuHistory30d = \Illuminate\Support\Facades\Cache::remember('admin_cpu_history_30d', 300, function () { |
|
| 199 | + $cpuHistory30d = \Illuminate\Support\Facades\Cache::remember('admin_cpu_history_30d', 300, function() { |
|
| 200 | 200 | return $this->systemMetricsService->getDailyMetrics('cpu', 30); |
| 201 | 201 | }); |
| 202 | 202 | |
| 203 | - $ramHistory24h = \Illuminate\Support\Facades\Cache::remember('admin_ram_history_24h', 300, function () { |
|
| 203 | + $ramHistory24h = \Illuminate\Support\Facades\Cache::remember('admin_ram_history_24h', 300, function() { |
|
| 204 | 204 | return $this->systemMetricsService->getHourlyMetrics('ram', 24); |
| 205 | 205 | }); |
| 206 | 206 | |
| 207 | - $ramHistory30d = \Illuminate\Support\Facades\Cache::remember('admin_ram_history_30d', 300, function () { |
|
| 207 | + $ramHistory30d = \Illuminate\Support\Facades\Cache::remember('admin_ram_history_30d', 300, function() { |
|
| 208 | 208 | return $this->systemMetricsService->getDailyMetrics('ram', 30); |
| 209 | 209 | }); |
| 210 | 210 | |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | |
| 328 | 328 | // Get number of physical cores |
| 329 | 329 | preg_match_all('/^cpu cores\s*:\s*(\d+)/m', $cpuinfo, $coresMatches); |
| 330 | - if (! empty($coresMatches[1])) { |
|
| 330 | + if (!empty($coresMatches[1])) { |
|
| 331 | 331 | $info['cores'] = (int) $coresMatches[1][0]; |
| 332 | 332 | } |
| 333 | 333 | |
@@ -337,14 +337,14 @@ discard block |
||
| 337 | 337 | |
| 338 | 338 | // Get CPU model |
| 339 | 339 | preg_match('/^model name\s*:\s*(.+)$/m', $cpuinfo, $modelMatches); |
| 340 | - if (! empty($modelMatches[1])) { |
|
| 340 | + if (!empty($modelMatches[1])) { |
|
| 341 | 341 | $info['model'] = trim($modelMatches[1]); |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | // If cores is 0, try to get from physical id count |
| 345 | 345 | if ($info['cores'] === 0) { |
| 346 | 346 | preg_match_all('/^physical id\s*:\s*(\d+)/m', $cpuinfo, $physicalMatches); |
| 347 | - $uniquePhysical = ! empty($physicalMatches[1]) ? count(array_unique($physicalMatches[1])) : 1; |
|
| 347 | + $uniquePhysical = !empty($physicalMatches[1]) ? count(array_unique($physicalMatches[1])) : 1; |
|
| 348 | 348 | $info['cores'] = (int) ($info['threads'] / $uniquePhysical); |
| 349 | 349 | } |
| 350 | 350 | } |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | */ |
| 129 | 129 | private function getOverallStats(): array |
| 130 | 130 | { |
| 131 | - return \Illuminate\Support\Facades\Cache::remember('admin_invitation_stats', 300, function () { |
|
| 131 | + return \Illuminate\Support\Facades\Cache::remember('admin_invitation_stats', 300, function() { |
|
| 132 | 132 | return [ |
| 133 | 133 | 'total' => Invitation::count(), |
| 134 | 134 | 'pending' => Invitation::valid()->count(), |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | */ |
| 153 | 153 | private function getTopInviters(int $limit = 10): array |
| 154 | 154 | { |
| 155 | - return \Illuminate\Support\Facades\Cache::remember('admin_top_inviters', 300, function () use ($limit) { |
|
| 155 | + return \Illuminate\Support\Facades\Cache::remember('admin_top_inviters', 300, function() use ($limit) { |
|
| 156 | 156 | return User::select('users.*') |
| 157 | 157 | ->selectRaw('COUNT(invitations.id) as total_invitations') |
| 158 | 158 | ->selectRaw('COUNT(CASE WHEN invitations.used_at IS NOT NULL THEN 1 END) as successful_invitations') |
@@ -183,7 +183,7 @@ |
||
| 183 | 183 | $adminManuallySetExpiry = false; |
| 184 | 184 | if ($request->has('rolechangedate')) { |
| 185 | 185 | $roleChangeDate = $request->input('rolechangedate'); |
| 186 | - if (! empty($roleChangeDate)) { |
|
| 186 | + if (!empty($roleChangeDate)) { |
|
| 187 | 187 | User::updateUserRoleChangeDate($editedUser->id, $roleChangeDate); |
| 188 | 188 | $adminManuallySetExpiry = true; // Flag that admin set custom expiry |
| 189 | 189 | } else { |