simplify playtime range display

This commit is contained in:
Lukáš Kucharczyk 2023-11-06 12:05:39 +01:00
parent 288bf65afb
commit 5e6a5a4024
3 changed files with 15 additions and 5 deletions

View File

@ -1,3 +1,8 @@
## Unreleased
### Improved
* game overview: simplify playtime range display
## 1.3.0 / 2023-11-05 15:09+01:00 ## 1.3.0 / 2023-11-05 15:09+01:00
### New ### New

View File

@ -15,9 +15,7 @@
<h2 class="text-lg my-2 ml-2"> <h2 class="text-lg my-2 ml-2">
{{ total_hours }} <span class="dark:text-slate-500">total</span> {{ total_hours }} <span class="dark:text-slate-500">total</span>
{{ session_average }} <span class="dark:text-slate-500">avg</span> {{ session_average }} <span class="dark:text-slate-500">avg</span>
({{ first_session.timestamp_start | date:"M Y"}} ({{ playrange }}) </h2>
{{ last_session.timestamp_start | date:"M Y"}}) </h2>
<hr class="border-slate-500"> <hr class="border-slate-500">
<h1 class="text-3xl mt-4 mb-1">Editions <span class="dark:text-slate-500">({{ editions.count }})</span></h1> <h1 class="text-3xl mt-4 mb-1">Editions <span class="dark:text-slate-500">({{ editions.count }})</span></h1>
<ul> <ul>

View File

@ -137,8 +137,15 @@ def view_game(request, game_id=None):
# here first and last is flipped # here first and last is flipped
# because sessions are ordered from newest to oldest # because sessions are ordered from newest to oldest
# so the most recent are on top # so the most recent are on top
context["last_session"] = context["sessions"].first() playrange_start = context["sessions"].last().timestamp_start.strftime("%b %Y")
context["first_session"] = context["sessions"].last() playrange_end = context["sessions"].first().timestamp_start.strftime("%b %Y")
context["playrange"] = (
playrange_start
if playrange_start == playrange_end
else f"{playrange_start}{playrange_end}"
)
context["sessions_with_notes"] = context["sessions"].exclude(note="") context["sessions_with_notes"] = context["sessions"].exclude(note="")
request.session["return_path"] = request.path request.session["return_path"] = request.path
return render(request, "view_game.html", context) return render(request, "view_game.html", context)