From 995cc40a5f821330fc45b5f6e16c7720eb5785b6 Mon Sep 17 00:00:00 2001 From: Josef Citrine Date: Fri, 9 Sep 2016 21:37:07 +0100 Subject: [PATCH] Hidden archived artists' tracks from recent tracks --- .../Controllers/Api/Web/DashboardController.php | 4 ++++ app/Http/Controllers/Api/Web/TracksController.php | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/app/Http/Controllers/Api/Web/DashboardController.php b/app/Http/Controllers/Api/Web/DashboardController.php index de9239dd..0fdd0e88 100644 --- a/app/Http/Controllers/Api/Web/DashboardController.php +++ b/app/Http/Controllers/Api/Web/DashboardController.php @@ -39,6 +39,10 @@ class DashboardController extends ApiControllerBase ->orderBy('published_at', 'desc') ->take(30); + $recentQuery->whereHas('user', function($q) { + $q->whereIsArchived(false); + }); + $recentTracks = []; foreach ($recentQuery->get() as $track) { diff --git a/app/Http/Controllers/Api/Web/TracksController.php b/app/Http/Controllers/Api/Web/TracksController.php index aae95438..53504813 100644 --- a/app/Http/Controllers/Api/Web/TracksController.php +++ b/app/Http/Controllers/Api/Web/TracksController.php @@ -242,7 +242,10 @@ class TracksController extends ApiControllerBase */ private function applyFilters($query, $unknown = false) { + $has_filters = false; + if (Input::has('is_vocal')) { + $has_filters = true; $isVocal = \Input::get('is_vocal'); if ($isVocal == 'true') { $query->whereIsVocal(true); @@ -252,6 +255,7 @@ class TracksController extends ApiControllerBase } if (Input::has('in_album')) { + $has_filters = true; if (Input::get('in_album') == 'true') { $query->whereNotNull('album_id'); } else { @@ -260,10 +264,12 @@ class TracksController extends ApiControllerBase } if (Input::has('genres')) { + $has_filters = true; $query->whereIn('genre_id', Input::get('genres')); } if (Input::has('types') && !$unknown) { + $has_filters = true; $query->whereIn('track_type_id', Input::get('types')); } @@ -282,6 +288,7 @@ class TracksController extends ApiControllerBase } if (Input::has('songs')) { + $has_filters = true; // DISTINCT is needed here to avoid duplicate results // when a track is associated with multiple show songs. $query->distinct(); @@ -291,6 +298,12 @@ class TracksController extends ApiControllerBase $query->whereIn('show_song_track.show_song_id', Input::get('songs')); } + if (!$has_filters) { + $query->whereHas('user', function($q) { + $q->whereIsArchived(false); + }); + } + return $query; } }