refactor: split tmdb into movie_id and tv_id

Step 2 in cleaner meta fetching code.
This commit is contained in:
Roardom
2025-03-13 21:27:46 +00:00
parent 09f8404ada
commit 32cf8da4db
61 changed files with 1062 additions and 708 deletions
@@ -55,7 +55,7 @@ class YearlyOverviewController extends Controller
'yearly-overview:'.$year.':top-movies',
fn () => Torrent::with('movie')
->select([
'tmdb',
'movie_id',
DB::raw('COUNT(h.user_id) as download_count'),
DB::raw('MIN(category_id) as category_id'),
])
@@ -67,9 +67,10 @@ class YearlyOverviewController extends Controller
'h',
fn ($join) => $join->on('torrents.id', '=', 'h.torrent_id')
)
->where('tmdb', '!=', 0)
->where('movie_id', '!=', 0)
->whereNotNull('movie_id')
->whereRelation('category', 'movie_meta', '=', true)
->groupBy('tmdb')
->groupBy('movie_id')
->orderByDesc('download_count')
->take(10)
->get()
@@ -78,7 +79,7 @@ class YearlyOverviewController extends Controller
'yearly-overview:'.$year.':bottom-movies',
fn () => Torrent::with('movie')
->select([
'tmdb',
'movie_id',
DB::raw('COUNT(h.user_id) as download_count'),
DB::raw('MIN(category_id) as category_id'),
])
@@ -90,9 +91,10 @@ class YearlyOverviewController extends Controller
'h',
fn ($join) => $join->on('torrents.id', '=', 'h.torrent_id')
)
->where('tmdb', '!=', 0)
->where('movie_id', '!=', 0)
->whereNotNull('movie_id')
->whereRelation('category', 'movie_meta', '=', true)
->groupBy('tmdb')
->groupBy('movie_id')
->orderBy('download_count')
->take(5)
->get()
@@ -101,7 +103,7 @@ class YearlyOverviewController extends Controller
'yearly-overview:'.$year.':top-tv',
fn () => Torrent::with('tv')
->select([
'tmdb',
'tv_id',
DB::raw('COUNT(h.user_id) as download_count'),
DB::raw('MIN(category_id) as category_id'),
])
@@ -113,9 +115,10 @@ class YearlyOverviewController extends Controller
'h',
fn ($join) => $join->on('torrents.id', '=', 'h.torrent_id')
)
->where('tmdb', '!=', 0)
->where('tv_id', '!=', 0)
->whereNotNull('tv_id')
->whereRelation('category', 'tv_meta', '=', true)
->groupBy('tmdb')
->groupBy('tv_id')
->orderByDesc('download_count')
->take(10)
->get()
@@ -124,7 +127,7 @@ class YearlyOverviewController extends Controller
'yearly-overview:'.$year.':bottom-tv',
fn () => Torrent::with('tv')
->select([
'tmdb',
'tv_id',
DB::raw('COUNT(h.user_id) as download_count'),
DB::raw('MIN(category_id) as category_id'),
])
@@ -136,9 +139,10 @@ class YearlyOverviewController extends Controller
'h',
fn ($join) => $join->on('torrents.id', '=', 'h.torrent_id')
)
->where('tmdb', '!=', 0)
->where('tv_id', '!=', 0)
->whereNotNull('tv_id')
->whereRelation('category', 'tv_meta', '=', true)
->groupBy('tmdb')
->groupBy('tv_id')
->orderBy('download_count')
->take(5)
->get()