mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-22 04:58:01 +01:00
Fixed an n+1 query.
This commit is contained in:
parent
6c83936ce6
commit
5314f5accb
1 changed files with 4 additions and 2 deletions
|
@ -33,8 +33,10 @@ class TaxonomiesController extends ApiControllerBase
|
|||
{
|
||||
return \Response::json([
|
||||
'licenses' => License::all()->toArray(),
|
||||
'genres' => Genre::select('genres.*',
|
||||
DB::raw('(SELECT COUNT(id) FROM tracks WHERE tracks.genre_id = genres.id AND tracks.published_at IS NOT NULL) AS track_count'))->orderBy('name')->get()->toArray(),
|
||||
'genres' => Genre::with('trackCountRelation')
|
||||
->orderBy('name')
|
||||
->get()
|
||||
->toArray(),
|
||||
'track_types' => TrackType::select('track_types.*',
|
||||
DB::raw('(SELECT COUNT(id) FROM tracks WHERE tracks.track_type_id = track_types.id AND tracks.published_at IS NOT NULL) AS track_count'))
|
||||
->where('id', '!=', TrackType::UNCLASSIFIED_TRACK)
|
||||
|
|
Loading…
Reference in a new issue