diff --git a/VERSION b/VERSION index 197c4d5..005119b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.4.0 +2.4.1 diff --git a/api/web_routes.py b/api/web_routes.py index a81000f..dc9b773 100644 --- a/api/web_routes.py +++ b/api/web_routes.py @@ -375,16 +375,16 @@ async def get_missing_dates_report(dependencies: dict): episodes_with_dates = db._get_first_value(cursor.fetchone()) else: cursor.execute("SELECT COUNT(*) FROM movies WHERE dateadded IS NOT NULL AND dateadded != ''") - movies_with_dates = cursor.fetchone()[0] + movies_with_dates = db._get_first_value(cursor.fetchone()) cursor.execute("SELECT COUNT(*) FROM movies") - total_movies = cursor.fetchone()[0] + total_movies = db._get_first_value(cursor.fetchone()) cursor.execute("SELECT COUNT(*) FROM episodes WHERE dateadded IS NOT NULL AND dateadded != ''") - episodes_with_dates = cursor.fetchone()[0] + episodes_with_dates = db._get_first_value(cursor.fetchone()) cursor.execute("SELECT COUNT(*) FROM episodes") - total_episodes = cursor.fetchone()[0] + total_episodes = db._get_first_value(cursor.fetchone()) return { "summary": { @@ -443,11 +443,17 @@ async def get_dashboard_stats(dependencies: dict): episodes_no_valid_source = db._get_first_value(cursor.fetchone()) # Recent activity (last 7 days) - cursor.execute(""" - SELECT COUNT(*) FROM processing_history - WHERE processed_at > datetime('now', '-7 days') - """) - recent_activity = cursor.fetchone()[0] + if db.db_type == "postgresql": + cursor.execute(""" + SELECT COUNT(*) FROM processing_history + WHERE processed_at > NOW() - INTERVAL '7 days' + """) + else: + cursor.execute(""" + SELECT COUNT(*) FROM processing_history + WHERE processed_at > datetime('now', '-7 days') + """) + recent_activity = db._get_first_value(cursor.fetchone()) # Source distribution for movies cursor.execute(""" @@ -457,7 +463,10 @@ async def get_dashboard_stats(dependencies: dict): GROUP BY source ORDER BY count DESC """) - movie_sources = [{"source": row[0], "count": row[1]} for row in cursor.fetchall()] + if db.db_type == "postgresql": + movie_sources = [{"source": list(row.values())[0], "count": list(row.values())[1]} for row in cursor.fetchall()] + else: + movie_sources = [{"source": row[0], "count": row[1]} for row in cursor.fetchall()] # Source distribution for episodes cursor.execute(""" @@ -467,7 +476,10 @@ async def get_dashboard_stats(dependencies: dict): GROUP BY source ORDER BY count DESC """) - episode_sources = [{"source": row[0], "count": row[1]} for row in cursor.fetchall()] + if db.db_type == "postgresql": + episode_sources = [{"source": list(row.values())[0], "count": list(row.values())[1]} for row in cursor.fetchall()] + else: + 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