From ead38fdb13abb406065cef0743d7e411cb27eaf3 Mon Sep 17 00:00:00 2001 From: Tyler Hoang Date: Wed, 6 May 2026 18:05:07 -0700 Subject: Add genre tracking and year-in-review improvements Adds genre field to Film model with TMDB enrichment. Genres populate from TMDB detail fetch during add/edit and bulk enrichment. Genre metadata displays on film cards, detail page (Production section), stats page (top genres panel), and year-in-review (by decade and genre breakdowns). Auto-detects rewatches when adding films via TMDB autocomplete - if a film with the same TMDB ID already exists in diary, pre-fills rewatch checkbox and count. Rewatch count now displays on film cards as "Rewatch #N". Stats page now shows: - Top genres (most watched) - Film decades (sorted chronologically) - Already shows: directors, companions, star distribution, rewatch rate Year-in-review shows decades and genres alongside monthly activity and companions. Bulk enrichment endpoint (/data/enrich-posters) now fetches missing genre metadata along with posters and TMDB IDs. Co-Authored-By: Claude Haiku 4.5 --- routers/films.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'routers/films.py') diff --git a/routers/films.py b/routers/films.py index 4ac023c..e432a5c 100644 --- a/routers/films.py +++ b/routers/films.py @@ -123,6 +123,7 @@ def _film_payload(form) -> dict: "director": _empty_to_none(_form_value(form, "director")), "year": _parse_int(_form_value(form, "year"), "Year"), "country": _empty_to_none(_form_value(form, "country")), + "genre": _empty_to_none(_form_value(form, "genre")), "language": _empty_to_none(_form_value(form, "language")), "runtime": _parse_optional_nonnegative_int(_form_value(form, "runtime"), "Runtime"), "date_watched": _parse_date(_form_value(form, "date_watched")), @@ -332,6 +333,12 @@ def abandoned_feed( ) +@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() + return {"count": count} + + @router.get("/films/new") def new_film(request: Request): return templates.TemplateResponse( -- cgit v1.3-2-g0d8e