diff --git a/VERSION b/VERSION index ccbccc3..b1b25a5 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.2.0 +2.2.2 diff --git a/api/web_routes.py b/api/web_routes.py index 3e00390..0ff0b70 100644 --- a/api/web_routes.py +++ b/api/web_routes.py @@ -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, diff --git a/processors/movie_processor.py b/processors/movie_processor.py index 81a1e1e..e813e5f 100644 --- a/processors/movie_processor.py +++ b/processors/movie_processor.py @@ -159,8 +159,9 @@ class MovieProcessor: source = nfo_data["source"] released = nfo_data.get("released") - # Cache NFO data in database for future lookups - self.db.upsert_movie_dates(imdb_id, dateadded, released, source, True) + # Cache NFO data in database for future lookups + # Fixed parameter order: imdb_id, released, dateadded, source + self.db.upsert_movie_dates(imdb_id, released, dateadded, source, True) _log("INFO", f"✅ Cached NFO data in database for {imdb_id}") # Update file mtimes if enabled (NFO is already correct) @@ -179,7 +180,8 @@ class MovieProcessor: released = existing_nfo_data.get("released") # Cache existing data in database and add proper NFOGuard formatting - self.db.upsert_movie_dates(imdb_id, dateadded, released, source, True) + # Fixed parameter order: imdb_id, released, dateadded, source + self.db.upsert_movie_dates(imdb_id, released, dateadded, source, True) _log("INFO", f"✅ Cached existing NFO data in database for {imdb_id}") # Update NFO file to add NFOGuard formatting (lockdata, comment) diff --git a/static/js/app.js b/static/js/app.js index f375b35..e398524 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -114,17 +114,25 @@ async function loadDashboard() { function updateDashboardStats() { if (!dashboardData) return; - document.getElementById('movies-total').textContent = dashboardData.movies_total || 0; - document.getElementById('movies-with-dates').textContent = `${dashboardData.movies_with_dates || 0} with dates`; + const moviesTotal = dashboardData.movies_total || 0; + const moviesWithDates = dashboardData.movies_with_dates || 0; + const moviesWithoutDates = dashboardData.movies_without_dates || 0; + + const episodesTotal = dashboardData.episodes_total || 0; + const episodesWithDates = dashboardData.episodes_with_dates || 0; + const episodesWithoutDates = dashboardData.episodes_without_dates || 0; + + document.getElementById('movies-total').textContent = moviesTotal; + document.getElementById('movies-with-dates').textContent = `${moviesWithDates} with dates, ${moviesWithoutDates} without`; document.getElementById('series-total').textContent = dashboardData.series_count || 0; - document.getElementById('episodes-total').textContent = `${dashboardData.episodes_total || 0} episodes`; + document.getElementById('episodes-total').textContent = `${episodesTotal} episodes (${episodesWithDates} with dates, ${episodesWithoutDates} without)`; - const missingTotal = (dashboardData.movies_missing_dates || 0) + (dashboardData.episodes_missing_dates || 0); + const missingTotal = moviesWithoutDates + episodesWithoutDates; document.getElementById('missing-dates-total').textContent = missingTotal; const noValidTotal = (dashboardData.movies_no_valid_source || 0) + (dashboardData.episodes_no_valid_source || 0); - document.getElementById('no-valid-source-total').textContent = `${noValidTotal} no valid source`; + document.getElementById('no-valid-source-total').textContent = `${moviesWithoutDates} movies, ${episodesWithoutDates} episodes without dates`; document.getElementById('recent-activity').textContent = dashboardData.recent_activity_count || 0; }