update to tv
Local Docker Build (Dev) / build-dev (push) Successful in 6s

This commit is contained in:
2025-11-03 20:40:42 -05:00
parent a326825347
commit d501c4364c
5 changed files with 28 additions and 17 deletions
+10 -6
View File
@@ -177,8 +177,8 @@ async def get_tv_series_list(dependencies: dict,
db = dependencies["db"]
# Validate date_filter values
if date_filter and date_filter not in ['complete', 'incomplete', 'none']:
raise HTTPException(status_code=422, detail=f"Invalid date_filter: must be 'complete', 'incomplete', or 'none', got '{date_filter}'")
if date_filter and date_filter not in ['complete', 'incomplete', 'none', 'skipped']:
raise HTTPException(status_code=422, detail=f"Invalid date_filter: must be 'complete', 'incomplete', 'none', or 'skipped', got '{date_filter}'")
with db.get_connection() as conn:
cursor = conn.cursor()
@@ -211,6 +211,9 @@ async def get_tv_series_list(dependencies: dict,
elif date_filter == "none":
# No episodes have dates
having_conditions.append("COUNT(e.episode) > 0 AND COUNT(CASE WHEN e.dateadded IS NOT NULL THEN 1 END) = 0")
elif date_filter == "skipped":
# Has skipped episodes
having_conditions.append("COUNT(CASE WHEN e.skipped = TRUE THEN 1 END) > 0")
where_clause = " AND ".join(where_conditions) if where_conditions else "1=1"
having_clause = " AND ".join(having_conditions) if having_conditions else ""
@@ -242,13 +245,14 @@ async def get_tv_series_list(dependencies: dict,
having_part = f" HAVING {having_clause}" if having_clause else ""
# PostgreSQL query
query = f"""
SELECT
s.imdb_id,
s.path,
SELECT
s.imdb_id,
s.path,
s.last_updated,
COUNT(e.episode) as total_episodes,
COUNT(CASE WHEN e.dateadded IS NOT NULL THEN 1 END) as episodes_with_dates,
COUNT(CASE WHEN e.has_video_file = TRUE THEN 1 END) as episodes_with_video
COUNT(CASE WHEN e.has_video_file = TRUE THEN 1 END) as episodes_with_video,
COUNT(CASE WHEN e.skipped = TRUE THEN 1 END) as episodes_skipped
FROM series s
LEFT JOIN episodes e ON s.imdb_id = e.imdb_id
WHERE {where_clause}