diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php index 450da761..821cfef4 100644 --- a/app/Http/Controllers/AdminController.php +++ b/app/Http/Controllers/AdminController.php @@ -48,4 +48,9 @@ class AdminController extends Controller { return View::make('shared.null'); } + + public function getClassifierQueue() + { + return View::make('shared.null'); + } } diff --git a/app/Http/Controllers/Api/Web/TracksController.php b/app/Http/Controllers/Api/Web/TracksController.php index d0bfdb5e..ee24c2bb 100644 --- a/app/Http/Controllers/Api/Web/TracksController.php +++ b/app/Http/Controllers/Api/Web/TracksController.php @@ -27,9 +27,12 @@ use Poniverse\Ponyfm\Commands\EditTrackCommand; use Poniverse\Ponyfm\Commands\UploadTrackCommand; use Poniverse\Ponyfm\Http\Controllers\ApiControllerBase; use Poniverse\Ponyfm\Jobs\EncodeTrackFile; +use Poniverse\Ponyfm\Models\Genre; use Poniverse\Ponyfm\Models\ResourceLogItem; use Poniverse\Ponyfm\Models\TrackFile; use Poniverse\Ponyfm\Models\Track; +use Poniverse\Ponyfm\Models\TrackType; +use Poniverse\Ponyfm\Models\TrackTypes; use Auth; use Input; use Poniverse\Ponyfm\Models\User; @@ -131,7 +134,7 @@ class TracksController extends ApiControllerBase return Response::json(['url' => $url], 200); } - public function getIndex($all = false) + public function getIndex($all = false, $unknown = false) { $page = 1; $perPage = 45; @@ -155,7 +158,7 @@ class TracksController extends ApiControllerBase ->with('user', 'genre', 'cover', 'album', 'album.user'); } - $this->applyFilters($query); + $this->applyFilters($query, $unknown); $totalCount = $query->count(); $this->applyOrdering($query); @@ -182,6 +185,12 @@ class TracksController extends ApiControllerBase return $this->getIndex(true); } + public function getClassifierQueue() + { + $this->authorize('access-admin-area'); + return $this->getIndex(true, true); + } + public function getOwned(User $user) { $query = Track::summary()->where('user_id', $user->id)->orderBy('created_at', 'desc'); @@ -231,7 +240,7 @@ class TracksController extends ApiControllerBase * @param $query * @return mixed */ - private function applyFilters($query) + private function applyFilters($query, $unknown = false) { if (Input::has('is_vocal')) { $isVocal = \Input::get('is_vocal'); @@ -254,10 +263,23 @@ class TracksController extends ApiControllerBase $query->whereIn('genre_id', Input::get('genres')); } - if (Input::has('types')) { + if (Input::has('types') && !$unknown) { $query->whereIn('track_type_id', Input::get('types')); } + if ($unknown) { + $query->where(function($q) { + $unknownGenre = Genre::where('name', 'Unknown')->first(); + + $q->where('track_type_id', TrackType::UNCLASSIFIED_TRACK); + + if ($unknownGenre) { + $q->orWhere('genre_id', $unknownGenre->id); + } + }); + + } + if (Input::has('songs')) { // DISTINCT is needed here to avoid duplicate results // when a track is associated with multiple show songs. diff --git a/app/Http/routes.php b/app/Http/routes.php index 88fa844e..4539cae2 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -177,6 +177,7 @@ Route::group(['prefix' => 'api/web'], function() { Route::delete('/showsongs/{id}', 'Api\Web\ShowSongsController@deleteSong')->where('id', '\d+'); Route::get('/tracks', 'Api\Web\TracksController@getAllTracks'); + Route::get('/tracks/unclassified', 'Api\Web\TracksController@getClassifierQueue'); }); Route::post('/auth/logout', 'Api\Web\AuthController@postLogout'); @@ -186,6 +187,7 @@ Route::group(['prefix' => 'api/web'], function() { Route::group(['prefix' => 'admin', 'middleware' => ['auth', 'can:access-admin-area']], function() { Route::get('/genres', 'AdminController@getGenres'); Route::get('/tracks', 'AdminController@getTracks'); + Route::get('/tracks/unclassified', 'AdminController@getClassifierQueue'); Route::get('/show-songs', 'AdminController@getShowSongs'); Route::get('/users', 'AdminController@getUsers'); Route::get('/', 'AdminController@getIndex'); diff --git a/public/templates/admin/_layout.html b/public/templates/admin/_layout.html index 5d1a4700..f94c5b84 100644 --- a/public/templates/admin/_layout.html +++ b/public/templates/admin/_layout.html @@ -1,5 +1,6 @@