This commit is contained in:
@@ -541,6 +541,10 @@ async def manual_scan(background_tasks: BackgroundTasks, path: Optional[str] = N
|
||||
raise HTTPException(status_code=400, detail="scan_type must be 'both', 'tv', or 'movies'")
|
||||
|
||||
async def run_scan():
|
||||
from datetime import datetime
|
||||
start_time = datetime.now()
|
||||
print(f"🚀 MANUAL SCAN STARTED: {scan_type} scan initiated at {start_time.strftime('%Y-%m-%d %H:%M:%S')}")
|
||||
|
||||
paths_to_scan = []
|
||||
if path:
|
||||
paths_to_scan = [Path(path)]
|
||||
@@ -620,6 +624,13 @@ async def manual_scan(background_tasks: BackgroundTasks, path: Optional[str] = N
|
||||
print(f"INFO: Processed {movie_count} movies, yielding to other requests...")
|
||||
|
||||
print(f"INFO: Completed movie scan: {movie_count} movies processed in {scan_path}")
|
||||
|
||||
# Log scan completion with duration
|
||||
end_time = datetime.now()
|
||||
duration = end_time - start_time
|
||||
duration_str = str(duration).split('.')[0] # Remove microseconds
|
||||
print(f"✅ MANUAL SCAN COMPLETED: {scan_type} scan finished at {end_time.strftime('%Y-%m-%d %H:%M:%S')}")
|
||||
print(f"⏱️ MANUAL SCAN DURATION: {duration_str} (total time: {duration.total_seconds():.1f} seconds)")
|
||||
|
||||
background_tasks.add_task(run_scan)
|
||||
return {"status": "started", "message": f"Manual {scan_type} scan started"}
|
||||
|
||||
+8
-4
@@ -427,6 +427,8 @@ async def get_missing_dates_report(dependencies: dict):
|
||||
movie['title'] = Path(movie['path']).name if movie['path'] else movie['imdb_id']
|
||||
except:
|
||||
movie['title'] = movie['imdb_id']
|
||||
# Map source to user-friendly description
|
||||
movie['source_description'] = map_source_to_description(movie.get('source'))
|
||||
movies_missing.append(movie)
|
||||
|
||||
# Episodes without dates - PostgreSQL compatible
|
||||
@@ -453,6 +455,8 @@ async def get_missing_dates_report(dependencies: dict):
|
||||
episode['series_title'] = Path(episode['path']).name if episode['path'] else episode['imdb_id']
|
||||
except:
|
||||
episode['series_title'] = episode['imdb_id']
|
||||
# Map source to user-friendly description
|
||||
episode['source_description'] = map_source_to_description(episode.get('source'))
|
||||
episodes_missing.append(episode)
|
||||
|
||||
# Summary statistics - PostgreSQL compatible
|
||||
@@ -556,9 +560,9 @@ async def get_dashboard_stats(dependencies: dict):
|
||||
ORDER BY count DESC
|
||||
""")
|
||||
if db.db_type == "postgresql":
|
||||
movie_sources = [{"source": list(row.values())[0], "count": list(row.values())[1]} for row in cursor.fetchall()]
|
||||
movie_sources = [{"source": list(row.values())[0], "source_description": map_source_to_description(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()]
|
||||
movie_sources = [{"source": row[0], "source_description": map_source_to_description(row[0]), "count": row[1]} for row in cursor.fetchall()]
|
||||
|
||||
# Source distribution for episodes
|
||||
cursor.execute("""
|
||||
@@ -569,9 +573,9 @@ async def get_dashboard_stats(dependencies: dict):
|
||||
ORDER BY count DESC
|
||||
""")
|
||||
if db.db_type == "postgresql":
|
||||
episode_sources = [{"source": list(row.values())[0], "count": list(row.values())[1]} for row in cursor.fetchall()]
|
||||
episode_sources = [{"source": list(row.values())[0], "source_description": map_source_to_description(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()]
|
||||
episode_sources = [{"source": row[0], "source_description": map_source_to_description(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
|
||||
|
||||
Reference in New Issue
Block a user