diff --git a/app/Http/Controllers/MediaController.php b/app/Http/Controllers/MediaController.php index 00b463d..ab41838 100644 --- a/app/Http/Controllers/MediaController.php +++ b/app/Http/Controllers/MediaController.php @@ -339,17 +339,17 @@ public function filters(Request $request) } $caseSql .= "WHEN duration > {$this->durationOtherMin()} THEN '120-' END"; - $durations = Media::select( + $durations = DB::table('media') + ->select( DB::raw("{$caseSql} as duration_range"), DB::raw('COUNT(*) as total') ) - ->whereNotNull('duration') + ->where('duration', '>', 0) // every positive duration falls into a bucket ->where(function ($q) { $q->where('visibility', 'public') ->orWhere('user_id', auth()->id()); }) ->groupBy('duration_range') - ->havingRaw('duration_range IS NOT NULL') ->get(); return response()->json([