summaryrefslogtreecommitdiff
path: root/routers
diff options
context:
space:
mode:
Diffstat (limited to 'routers')
-rw-r--r--routers/films.py16
-rw-r--r--routers/stats.py2
2 files changed, 18 insertions, 0 deletions
diff --git a/routers/films.py b/routers/films.py
index 449fd44..56f50c5 100644
--- a/routers/films.py
+++ b/routers/films.py
@@ -335,6 +335,22 @@ def abandoned_feed(
)
+@router.get("/films/find")
+def find_films_by_tmdb_id(tmdb_id: int, db: Session = Depends(get_db)):
+ films = db.query(Film).filter(Film.tmdb_id == tmdb_id).all()
+ return {
+ "matches": [
+ {
+ "id": f.id,
+ "shelf": f.shelf,
+ "title": f.title,
+ "date_watched": f.date_watched.isoformat() if f.date_watched else None,
+ }
+ for f in films
+ ]
+ }
+
+
@router.get("/films/check-rewatch")
def check_rewatch(tmdb_id: int, db: Session = Depends(get_db)):
count = db.query(Film).filter(Film.tmdb_id == tmdb_id, Film.shelf == "diary").count()
diff --git a/routers/stats.py b/routers/stats.py
index 15063cb..d600e5a 100644
--- a/routers/stats.py
+++ b/routers/stats.py
@@ -65,6 +65,7 @@ def _build_stats_payload(films: list[Film]) -> dict:
watched_with["solo"] += 1
total_watched = len(films)
+ total_runtime_minutes = sum(film.runtime for film in films if film.runtime)
title_groups = defaultdict(list)
for film in films:
@@ -103,6 +104,7 @@ def _build_stats_payload(films: list[Film]) -> dict:
"requires_date_watched": True,
},
"total_watched": total_watched,
+ "total_runtime_minutes": total_runtime_minutes,
"films_per_country": [
{"country": country, "count": count}
for country, count in sorted(countries.items(), key=lambda item: (-item[1], item[0]))