summaryrefslogtreecommitdiff
path: root/templates/year_review.html
blob: 1234e8022dfd7c059fa534223f7a4af6d37dc948 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
{% extends "base.html" %}

{% block title %}{{ selected_year }} Year in Review · Lumière{% endblock %}

{% block content %}
  <section class="review-hero">
    <div>
      <p class="eyebrow">Year in Review</p>
      <h1>{{ selected_year }}</h1>
      <p class="review-intro">A snapshot of the films you logged that year.</p>
    </div>

    <form class="year-picker" method="get" action="/stats/year-in-review">
      <label for="year">Year</label>
      <select id="year" name="year" onchange="this.form.submit()">
        {% for option in available_years %}
          <option value="{{ option }}" {% if option == selected_year %}selected{% endif %}>{{ option }}</option>
        {% endfor %}
      </select>
    </form>
  </section>

  {% if total_watched == 0 %}
    <section class="empty-state">
      <p class="eyebrow">No entries</p>
      <h2>No diary films for this year</h2>
      <p>Pick another year or add more diary entries.</p>
    </section>
  {% else %}
    <section class="review-metrics">
      <article class="summary-card">
        <span class="summary-label">Films watched</span>
        <strong>{{ total_watched }}</strong>
      </article>
      <article class="summary-card">
        <span class="summary-label">Average stars</span>
        <strong>{{ "%.1f"|format(average_stars) }}</strong>
      </article>
      <article class="summary-card">
        <span class="summary-label">Rewatch rate</span>
        <strong>{{ (rewatch_rate.rate * 100)|round(0) }}%</strong>
      </article>
      <article class="summary-card">
        <span class="summary-label">Top director</span>
        <strong>{% if top_director %}{{ top_director.director }}{% else %}—{% endif %}</strong>
      </article>
      <article class="summary-card">
        <span class="summary-label">Top month</span>
        <strong>{% if top_month %}{{ top_month.month }}{% else %}—{% endif %}</strong>
      </article>
    </section>

    <section class="review-grid">
      <article class="review-panel review-panel-wide">
        <p class="eyebrow">Monthly activity</p>
        <div class="year-bars">
          {% set max_month = films_per_month | map(attribute='count') | max if films_per_month else 1 %}
          {% for item in films_per_month %}
            <div class="year-bar-row">
              <span>{{ item.month[:3] }}</span>
              <div class="year-bar-track">
                <div class="year-bar-fill" style="width: {{ (item.count / max_month * 100) if max_month else 0 }}%"></div>
              </div>
              <strong>{{ item.count }}</strong>
            </div>
          {% endfor %}
        </div>
      </article>

      <article class="review-panel">
        <p class="eyebrow">Stars</p>
        <div class="stats-bars">
          {% set max_stars = star_distribution | map(attribute='count') | max if star_distribution else 1 %}
          {% for item in star_distribution %}
            <div class="stats-bar-row">
              <span>{{ item.stars }} star</span>
              <div class="stats-bar-track"><div class="stats-bar-fill" style="width: {{ (item.count / max_stars * 100) if max_stars else 0 }}%"></div></div>
              <strong>{{ item.count }}</strong>
            </div>
          {% endfor %}
        </div>
      </article>

      <article class="review-panel">
        <p class="eyebrow">Companions</p>
        <ol class="stats-list">
          {% for item in watched_with_breakdown %}
            <li><span>{{ item.watched_with }}</span><strong>{{ item.count }}</strong></li>
          {% endfor %}
        </ol>
      </article>
    </section>

    <section class="review-panel">
      <p class="eyebrow">Highlights</p>
      <div class="highlight-grid">
        {% if highlight_films.highest_rated %}
          {% for film in highlight_films.highest_rated %}
            <article class="highlight-card">
              <a class="poster-frame" href="/films/{{ film.id }}">
                {% if film.poster_url %}
                  <img src="{{ film.poster_url }}" alt="{{ film.title }} poster" loading="lazy">
                {% else %}
                  <span>{{ film.title[:1] }}</span>
                {% endif %}
              </a>
              <div>
                <h2><a href="/films/{{ film.id }}">{{ film.title }}</a></h2>
                <p class="muted">{{ film.director or "Unknown director" }}</p>
                <p class="highlight-meta">
                  {% if film.date_watched %}{{ film.date_watched }}{% endif %}
                  {% if film.stars %} · {% for _ in range(film.stars) %}✦{% endfor %}{% endif %}
                </p>
                {% if film.notes_excerpt %}
                  <p class="notes-preview">{{ film.notes_excerpt }}</p>
                {% endif %}
              </div>
            </article>
          {% endfor %}
        {% endif %}

        {% if highlight_films.first_watch %}
          <article class="highlight-card">
            <a class="poster-frame" href="/films/{{ highlight_films.first_watch.id }}">
              {% if highlight_films.first_watch.poster_url %}
                <img src="{{ highlight_films.first_watch.poster_url }}" alt="{{ highlight_films.first_watch.title }} poster" loading="lazy">
              {% else %}
                <span>{{ highlight_films.first_watch.title[:1] }}</span>
              {% endif %}
            </a>
            <div>
              <p class="summary-label">First watch</p>
              <h2><a href="/films/{{ highlight_films.first_watch.id }}">{{ highlight_films.first_watch.title }}</a></h2>
              <p class="muted">{{ highlight_films.first_watch.date_watched }}</p>
            </div>
          </article>
        {% endif %}

        {% if highlight_films.last_watch %}
          <article class="highlight-card">
            <a class="poster-frame" href="/films/{{ highlight_films.last_watch.id }}">
              {% if highlight_films.last_watch.poster_url %}
                <img src="{{ highlight_films.last_watch.poster_url }}" alt="{{ highlight_films.last_watch.title }} poster" loading="lazy">
              {% else %}
                <span>{{ highlight_films.last_watch.title[:1] }}</span>
              {% endif %}
            </a>
            <div>
              <p class="summary-label">Last watch</p>
              <h2><a href="/films/{{ highlight_films.last_watch.id }}">{{ highlight_films.last_watch.title }}</a></h2>
              <p class="muted">{{ highlight_films.last_watch.date_watched }}</p>
            </div>
          </article>
        {% endif %}

        {% if highlight_films.most_rewatched %}
          <article class="highlight-card">
            <a class="poster-frame" href="/films/{{ highlight_films.most_rewatched.id }}">
              {% if highlight_films.most_rewatched.poster_url %}
                <img src="{{ highlight_films.most_rewatched.poster_url }}" alt="{{ highlight_films.most_rewatched.title }} poster" loading="lazy">
              {% else %}
                <span>{{ highlight_films.most_rewatched.title[:1] }}</span>
              {% endif %}
            </a>
            <div>
              <p class="summary-label">Most rewatched</p>
              <h2><a href="/films/{{ highlight_films.most_rewatched.id }}">{{ highlight_films.most_rewatched.title }}</a></h2>
              <p class="muted">{{ highlight_films.most_rewatched.rewatch_count }} rewatches</p>
            </div>
          </article>
        {% endif %}
      </div>
    </section>
  {% endif %}
{% endblock %}