This commit is contained in:
+32
-5
@@ -133,9 +133,24 @@ async def get_tv_series_list(dependencies: dict,
|
|||||||
where_clause = " AND ".join(where_conditions) if where_conditions else "1=1"
|
where_clause = " AND ".join(where_conditions) if where_conditions else "1=1"
|
||||||
having_clause = " AND ".join(having_conditions) if having_conditions else ""
|
having_clause = " AND ".join(having_conditions) if having_conditions else ""
|
||||||
|
|
||||||
# Get total count
|
# Get total count with same filtering logic as main query
|
||||||
count_query = f"SELECT COUNT(*) FROM series s WHERE {where_clause}"
|
if having_clause:
|
||||||
cursor.execute(count_query, params)
|
# 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]
|
total_count = cursor.fetchone()[0]
|
||||||
|
|
||||||
# Get series with episode statistics
|
# 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 != ''")
|
cursor.execute("SELECT COUNT(*) FROM movies WHERE dateadded IS NOT NULL AND dateadded != ''")
|
||||||
movies_with_dates = cursor.fetchone()[0]
|
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 != ''")
|
cursor.execute("SELECT COUNT(*) FROM episodes WHERE dateadded IS NOT NULL AND dateadded != ''")
|
||||||
episodes_with_dates = cursor.fetchone()[0]
|
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'")
|
cursor.execute("SELECT COUNT(*) FROM movies WHERE source = 'no_valid_date_source'")
|
||||||
movies_no_valid_source = cursor.fetchone()[0]
|
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()]
|
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
|
# Combine with enhanced stats
|
||||||
stats.update({
|
stats.update({
|
||||||
"movies_with_dates": movies_with_dates,
|
"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_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,
|
"movies_no_valid_source": movies_no_valid_source,
|
||||||
"episodes_no_valid_source": episodes_no_valid_source,
|
"episodes_no_valid_source": episodes_no_valid_source,
|
||||||
"recent_activity_count": recent_activity,
|
"recent_activity_count": recent_activity,
|
||||||
|
|||||||
@@ -160,7 +160,8 @@ class MovieProcessor:
|
|||||||
released = nfo_data.get("released")
|
released = nfo_data.get("released")
|
||||||
|
|
||||||
# Cache NFO data in database for future lookups
|
# Cache NFO data in database for future lookups
|
||||||
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 NFO data in database for {imdb_id}")
|
_log("INFO", f"✅ Cached NFO data in database for {imdb_id}")
|
||||||
|
|
||||||
# Update file mtimes if enabled (NFO is already correct)
|
# Update file mtimes if enabled (NFO is already correct)
|
||||||
@@ -179,7 +180,8 @@ class MovieProcessor:
|
|||||||
released = existing_nfo_data.get("released")
|
released = existing_nfo_data.get("released")
|
||||||
|
|
||||||
# Cache existing data in database and add proper NFOGuard formatting
|
# 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}")
|
_log("INFO", f"✅ Cached existing NFO data in database for {imdb_id}")
|
||||||
|
|
||||||
# Update NFO file to add NFOGuard formatting (lockdata, comment)
|
# Update NFO file to add NFOGuard formatting (lockdata, comment)
|
||||||
|
|||||||
+13
-5
@@ -114,17 +114,25 @@ async function loadDashboard() {
|
|||||||
function updateDashboardStats() {
|
function updateDashboardStats() {
|
||||||
if (!dashboardData) return;
|
if (!dashboardData) return;
|
||||||
|
|
||||||
document.getElementById('movies-total').textContent = dashboardData.movies_total || 0;
|
const moviesTotal = dashboardData.movies_total || 0;
|
||||||
document.getElementById('movies-with-dates').textContent = `${dashboardData.movies_with_dates || 0} with dates`;
|
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('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;
|
document.getElementById('missing-dates-total').textContent = missingTotal;
|
||||||
|
|
||||||
const noValidTotal = (dashboardData.movies_no_valid_source || 0) + (dashboardData.episodes_no_valid_source || 0);
|
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;
|
document.getElementById('recent-activity').textContent = dashboardData.recent_activity_count || 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user