1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2024-12-28 10:37:41 +00:00

Better episode count query

This commit is contained in:
Mark McDowall 2013-08-24 20:38:08 -07:00
parent ff2b62887c
commit 60dadf96a3

View file

@ -54,8 +54,8 @@ private string GetSelectClause()
{ {
return @"SELECT return @"SELECT
SeriesId, SeriesId,
SUM(CASE WHEN (Monitored = 1 OR Episodes.EpisodeFileId > 0) AND (AirdateUtc <= @currentDate OR Episodes.EpisodeFileId > 0) THEN 1 ELSE 0 END) AS EpisodeCount, SUM(CASE WHEN (Monitored = 1 AND AirdateUtc <= @currentDate) OR Episodes.EpisodeFileId > 0 THEN 1 ELSE 0 END) AS EpisodeCount,
SUM(CASE WHEN (Monitored = 1 OR Episodes.EpisodeFileId > 0) AND Episodes.EpisodeFileId > 0 THEN 1 ELSE 0 END) AS EpisodeFileCount, SUM(CASE WHEN Episodes.EpisodeFileId > 0 THEN 1 ELSE 0 END) AS EpisodeFileCount,
MAX(Episodes.SeasonNumber) as SeasonCount, MAX(Episodes.SeasonNumber) as SeasonCount,
MIN(CASE WHEN AirDateUtc < @currentDate THEN NULL ELSE AirDateUtc END) AS NextAiringString MIN(CASE WHEN AirDateUtc < @currentDate THEN NULL ELSE AirDateUtc END) AS NextAiringString
FROM Episodes"; FROM Episodes";