summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTyler Hoang <tyler@tylerhoang.xyz>2026-05-07 00:21:24 -0700
committerTyler Hoang <tyler@tylerhoang.xyz>2026-05-07 00:21:24 -0700
commit364634151d756ce28060e9a982019e7f7bdb17cc (patch)
tree43a7e8e79aab57cbf3938ed81cfb7204f9ed377d
parentefd4f1ea3cf9f3d7335ed718c5d7fd44354147f9 (diff)
Add rewatch history to film detail page
Display all watches for a film with dates, ratings, and companions. Show time elapsed between rewatches and highlight when rating changed. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
-rw-r--r--routers/films.py16
-rw-r--r--templates/detail.html31
2 files changed, 46 insertions, 1 deletions
diff --git a/routers/films.py b/routers/films.py
index e432a5c..c85d811 100644
--- a/routers/films.py
+++ b/routers/films.py
@@ -443,10 +443,24 @@ def get_films_partial(
async def film_detail(film_id: int, request: Request, db: Session = Depends(get_db)):
film = _get_film_or_404(db, film_id)
tmdb_context = await _film_tmdb_context(film)
+
+ rewatch_history = (
+ db.query(Film)
+ .filter(Film.title == film.title, Film.shelf == "diary")
+ .order_by(Film.date_watched.asc())
+ .all()
+ )
+
return templates.TemplateResponse(
request=request,
name="detail.html",
- context={"request": request, "film": film, "active_shelf": film.shelf, "tmdb_context": tmdb_context},
+ context={
+ "request": request,
+ "film": film,
+ "active_shelf": film.shelf,
+ "tmdb_context": tmdb_context,
+ "rewatch_history": rewatch_history,
+ },
)
diff --git a/templates/detail.html b/templates/detail.html
index 156dec2..325b0c1 100644
--- a/templates/detail.html
+++ b/templates/detail.html
@@ -87,6 +87,37 @@
</article>
</section>
+ {% if rewatch_history and rewatch_history|length > 1 %}
+ <section class="detail-panel">
+ <p class="eyebrow">Rewatches</p>
+ <div style="display: flex; flex-direction: column; gap: 12px;">
+ {% for entry in rewatch_history %}
+ <div style="display: flex; justify-content: space-between; align-items: center; padding-bottom: 12px; border-bottom: 1px solid var(--line);">
+ <div>
+ <p style="margin: 0 0 4px; color: var(--muted); font-size: 0.9rem;">{{ entry.date_watched }}</p>
+ <p style="margin: 0; display: flex; align-items: center; gap: 8px;">
+ <span style="color: var(--accent);">{% for _ in range(entry.stars) %}✦{% endfor %}</span>
+ {% if entry.watched_with %}<span style="color: var(--muted); font-size: 0.9rem;">with {{ entry.watched_with }}</span>{% endif %}
+ </p>
+ </div>
+ {% if loop.length > 1 and not loop.first %}
+ <span style="color: var(--subtle); font-size: 0.85rem; text-align: right;">
+ {% set prev_entry = rewatch_history[loop.index - 2] %}
+ {% if prev_entry.date_watched %}
+ {% set days = (entry.date_watched - prev_entry.date_watched).days %}
+ {{ days }}d
+ {% if entry.stars != prev_entry.stars %}
+ <span style="color: var(--accent);">({{ prev_entry.stars }}→{{ entry.stars }})</span>
+ {% endif %}
+ {% endif %}
+ </span>
+ {% endif %}
+ </div>
+ {% endfor %}
+ </div>
+ </section>
+ {% endif %}
+
{% if tmdb_context %}
<section class="detail-panel">
<p class="eyebrow">Summary</p>