From 84ac42e5be00fe7591a6946f27a33770b0270a41 Mon Sep 17 00:00:00 2001 From: Tyler Hoang Date: Thu, 7 May 2026 00:02:25 -0700 Subject: Add rewatch patterns stats panel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a "Rewatches" section to /stats that displays films you've watched multiple times, grouped by title. For each rewatched film, shows: - Watch count (e.g., "3×") - Rating history (e.g., ✦ → ✦✦ → ✦) with accent highlight when ratings drift - Days between first and last watch Changes: - routers/stats.py: Group films by title in _build_stats_payload, compute rewatch details (ratings, days between, rating change flag), add rewatch_patterns key - templates/stats.html: Add "Rewatches" panel HTML and JS renderer (renderLists) Co-Authored-By: Claude Haiku 4.5 --- templates/stats.html | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'templates') diff --git a/templates/stats.html b/templates/stats.html index 9b71679..6f271bd 100644 --- a/templates/stats.html +++ b/templates/stats.html @@ -98,6 +98,16 @@
    + +
    +
    +
    +

    Films

    +

    Rewatches

    +
    +
    +
    +
    {% endblock %} @@ -164,6 +174,26 @@ ${rate}% ${data.rewatch_rate.rewatched} of ${data.rewatch_rate.total_watched} watched films were rewatches. `; + + const rewatchPatterns = document.getElementById("rewatch-patterns-list"); + if (data.rewatch_patterns && data.rewatch_patterns.length > 0) { + rewatchPatterns.innerHTML = data.rewatch_patterns.map((item) => { + const stars = (n) => (n > 0 ? "✦".repeat(n) : "—"); + const ratingHistory = item.ratings.map(stars).join(" → "); + const drift = item.rating_changed + ? `${ratingHistory}` + : `${ratingHistory}`; + const gap = item.days_between != null + ? `${item.days_between}d apart` + : ""; + return `
    + ${item.title} + ${gap}${drift}${item.watches}× +
    `; + }).join(""); + } else { + rewatchPatterns.innerHTML = "

    No rewatches yet.

    "; + } } function renderHeatmap(days) { -- cgit v1.3-2-g0d8e