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