fix: get latest episode from season, not from all seasons
This commit is contained in:
parent
fa74651a80
commit
a15a472721
1 changed files with 15 additions and 6 deletions
|
@ -18,11 +18,14 @@ SELECT
|
||||||
'backdrop', CONCAT('/', df_backdrop.filename_disk),
|
'backdrop', CONCAT('/', df_backdrop.filename_disk),
|
||||||
'url', s.slug,
|
'url', s.slug,
|
||||||
'alt', CONCAT(s.title, ' (', s.year, ')'),
|
'alt', CONCAT(s.title, ' (', s.year, ')'),
|
||||||
'subtext', CASE
|
'subtext', COALESCE(
|
||||||
WHEN MAX(e.season_number) IS NOT NULL AND MAX(e.episode_number) IS NOT NULL
|
(SELECT CONCAT('S', e1.season_number, 'E', e1.episode_number)
|
||||||
THEN CONCAT('S', MAX(e.season_number), 'E', MAX(e.episode_number))
|
FROM episodes e1
|
||||||
ELSE s.year::TEXT
|
WHERE e1.show = s.id
|
||||||
END
|
ORDER BY e1.season_number DESC, e1.episode_number DESC
|
||||||
|
LIMIT 1),
|
||||||
|
s.year::TEXT
|
||||||
|
)
|
||||||
) AS grid,
|
) AS grid,
|
||||||
|
|
||||||
json_build_object(
|
json_build_object(
|
||||||
|
@ -32,7 +35,13 @@ SELECT
|
||||||
'url', s.slug,
|
'url', s.slug,
|
||||||
'image', CONCAT('/', df_art.filename_disk),
|
'image', CONCAT('/', df_art.filename_disk),
|
||||||
'backdrop', CONCAT('/', df_backdrop.filename_disk),
|
'backdrop', CONCAT('/', df_backdrop.filename_disk),
|
||||||
'formatted_episode', CONCAT('S', MAX(e.season_number), 'E', MAX(e.episode_number)),
|
'formatted_episode', COALESCE(
|
||||||
|
(SELECT CONCAT('S', e2.season_number, 'E', e2.episode_number)
|
||||||
|
FROM episodes e2
|
||||||
|
WHERE e2.show = s.id
|
||||||
|
ORDER BY e2.season_number DESC, e2.episode_number DESC
|
||||||
|
LIMIT 1)
|
||||||
|
),
|
||||||
'last_watched_at', MAX(e.last_watched_at)
|
'last_watched_at', MAX(e.last_watched_at)
|
||||||
) AS episode,
|
) AS episode,
|
||||||
|
|
||||||
|
|
Reference in a new issue