fix: data issue not populating
Local Docker Build (Dev) / build-dev (push) Successful in 4s

This commit is contained in:
2025-10-15 08:21:27 -04:00
parent 0dfc296bf4
commit 913aed1f60
4 changed files with 51 additions and 14 deletions
+32 -5
View File
@@ -133,9 +133,24 @@ async def get_tv_series_list(dependencies: dict,
where_clause = " AND ".join(where_conditions) if where_conditions else "1=1"
having_clause = " AND ".join(having_conditions) if having_conditions else ""
# Get total count
count_query = f"SELECT COUNT(*) FROM series s WHERE {where_clause}"
cursor.execute(count_query, params)
# Get total count with same filtering logic as main query
if having_clause:
# When using HAVING clause, need to count filtered results
count_query = f"""
SELECT COUNT(*) FROM (
SELECT s.imdb_id
FROM series s
LEFT JOIN episodes e ON s.imdb_id = e.imdb_id
WHERE {where_clause}
GROUP BY s.imdb_id
HAVING {having_clause}
) filtered_series
"""
cursor.execute(count_query, params + having_params)
else:
# Simple count when no HAVING clause
count_query = f"SELECT COUNT(*) FROM series s WHERE {where_clause}"
cursor.execute(count_query, params)
total_count = cursor.fetchone()[0]
# Get series with episode statistics
@@ -310,9 +325,15 @@ async def get_dashboard_stats(dependencies: dict):
cursor.execute("SELECT COUNT(*) FROM movies WHERE dateadded IS NOT NULL AND dateadded != ''")
movies_with_dates = cursor.fetchone()[0]
cursor.execute("SELECT COUNT(*) FROM movies WHERE dateadded IS NULL OR dateadded = ''")
movies_without_dates = cursor.fetchone()[0]
cursor.execute("SELECT COUNT(*) FROM episodes WHERE dateadded IS NOT NULL AND dateadded != ''")
episodes_with_dates = cursor.fetchone()[0]
cursor.execute("SELECT COUNT(*) FROM episodes WHERE dateadded IS NULL OR dateadded = ''")
episodes_without_dates = cursor.fetchone()[0]
cursor.execute("SELECT COUNT(*) FROM movies WHERE source = 'no_valid_date_source'")
movies_no_valid_source = cursor.fetchone()[0]
@@ -346,12 +367,18 @@ async def get_dashboard_stats(dependencies: dict):
""")
episode_sources = [{"source": row[0], "count": row[1]} for row in cursor.fetchall()]
# Calculate total missing dates (movies + episodes)
total_missing_dates = movies_without_dates + episodes_without_dates
# Combine with enhanced stats
stats.update({
"movies_with_dates": movies_with_dates,
"movies_missing_dates": stats["movies_total"] - movies_with_dates,
"movies_without_dates": movies_without_dates,
"movies_missing_dates": movies_without_dates, # Keep for backward compatibility
"episodes_with_dates": episodes_with_dates,
"episodes_missing_dates": stats["episodes_total"] - episodes_with_dates,
"episodes_without_dates": episodes_without_dates,
"episodes_missing_dates": episodes_without_dates, # Keep for backward compatibility
"total_missing_dates": total_missing_dates,
"movies_no_valid_source": movies_no_valid_source,
"episodes_no_valid_source": episodes_no_valid_source,
"recent_activity_count": recent_activity,