This commit is contained in:
+48
-8
@@ -55,7 +55,7 @@ async def get_movies_list(dependencies: dict,
|
||||
# Get total count
|
||||
count_query = f"SELECT COUNT(*) FROM movies WHERE {where_clause}"
|
||||
cursor.execute(count_query, params)
|
||||
total_count = cursor.fetchone()[0]
|
||||
total_count = db._get_first_value(cursor.fetchone())
|
||||
|
||||
# Get paginated results
|
||||
query = f"""
|
||||
@@ -150,7 +150,7 @@ async def get_tv_series_list(dependencies: dict,
|
||||
# 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]
|
||||
total_count = db._get_first_value(cursor.fetchone())
|
||||
|
||||
# Get series with episode statistics
|
||||
having_part = f" HAVING {having_clause}" if having_clause else ""
|
||||
@@ -313,7 +313,15 @@ async def get_missing_dates_report(dependencies: dict):
|
||||
with db.get_connection() as conn:
|
||||
cursor = conn.cursor()
|
||||
|
||||
# Movies without dates
|
||||
# Movies without dates - PostgreSQL compatible
|
||||
if db.db_type == "postgresql":
|
||||
cursor.execute("""
|
||||
SELECT imdb_id, path, released, source, last_updated
|
||||
FROM movies
|
||||
WHERE dateadded IS NULL OR source = 'no_valid_date_source'
|
||||
ORDER BY last_updated DESC
|
||||
""")
|
||||
else:
|
||||
cursor.execute("""
|
||||
SELECT imdb_id, path, released, source, last_updated
|
||||
FROM movies
|
||||
@@ -329,7 +337,16 @@ async def get_missing_dates_report(dependencies: dict):
|
||||
movie['title'] = movie['imdb_id']
|
||||
movies_missing.append(movie)
|
||||
|
||||
# Episodes without dates
|
||||
# Episodes without dates - PostgreSQL compatible
|
||||
if db.db_type == "postgresql":
|
||||
cursor.execute("""
|
||||
SELECT e.imdb_id, e.season, e.episode, e.aired, e.source, e.last_updated, s.path
|
||||
FROM episodes e
|
||||
JOIN series s ON e.imdb_id = s.imdb_id
|
||||
WHERE e.dateadded IS NULL OR e.source = 'no_valid_date_source'
|
||||
ORDER BY e.last_updated DESC
|
||||
""")
|
||||
else:
|
||||
cursor.execute("""
|
||||
SELECT e.imdb_id, e.season, e.episode, e.aired, e.source, e.last_updated, s.path
|
||||
FROM episodes e
|
||||
@@ -346,7 +363,17 @@ async def get_missing_dates_report(dependencies: dict):
|
||||
episode['series_title'] = episode['imdb_id']
|
||||
episodes_missing.append(episode)
|
||||
|
||||
# Summary statistics
|
||||
# Summary statistics - PostgreSQL compatible
|
||||
if db.db_type == "postgresql":
|
||||
cursor.execute("SELECT COUNT(*) FROM movies WHERE dateadded IS NOT NULL")
|
||||
movies_with_dates = db._get_first_value(cursor.fetchone())
|
||||
|
||||
cursor.execute("SELECT COUNT(*) FROM movies")
|
||||
total_movies = db._get_first_value(cursor.fetchone())
|
||||
|
||||
cursor.execute("SELECT COUNT(*) FROM episodes WHERE dateadded IS NOT NULL")
|
||||
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]
|
||||
|
||||
@@ -383,7 +410,20 @@ async def get_dashboard_stats(dependencies: dict):
|
||||
with db.get_connection() as conn:
|
||||
cursor = conn.cursor()
|
||||
|
||||
# Enhanced statistics
|
||||
# Enhanced statistics - PostgreSQL compatible
|
||||
if db.db_type == "postgresql":
|
||||
cursor.execute("SELECT COUNT(*) FROM movies WHERE dateadded IS NOT NULL")
|
||||
movies_with_dates = db._get_first_value(cursor.fetchone())
|
||||
|
||||
cursor.execute("SELECT COUNT(*) FROM movies WHERE dateadded IS NULL OR source = 'no_valid_date_source'")
|
||||
movies_without_dates = db._get_first_value(cursor.fetchone())
|
||||
|
||||
cursor.execute("SELECT COUNT(*) FROM episodes WHERE dateadded IS NOT NULL")
|
||||
episodes_with_dates = db._get_first_value(cursor.fetchone())
|
||||
|
||||
cursor.execute("SELECT COUNT(*) FROM episodes WHERE dateadded IS NULL OR source = 'no_valid_date_source'")
|
||||
episodes_without_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]
|
||||
|
||||
@@ -397,10 +437,10 @@ async def get_dashboard_stats(dependencies: dict):
|
||||
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]
|
||||
movies_no_valid_source = db._get_first_value(cursor.fetchone())
|
||||
|
||||
cursor.execute("SELECT COUNT(*) FROM episodes WHERE source = 'no_valid_date_source'")
|
||||
episodes_no_valid_source = cursor.fetchone()[0]
|
||||
episodes_no_valid_source = db._get_first_value(cursor.fetchone())
|
||||
|
||||
# Recent activity (last 7 days)
|
||||
cursor.execute("""
|
||||
|
||||
Reference in New Issue
Block a user