simplify playtime range display

This commit is contained in:
Lukáš Kucharczyk 2023-11-06 12:05:39 +01:00
parent 4552cf7616
commit e0b09e051a
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
### New

View File

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

View File

@ -137,8 +137,15 @@ def view_game(request, game_id=None):
# here first and last is flipped
# because sessions are ordered from newest to oldest
# so the most recent are on top
context["last_session"] = context["sessions"].first()
context["first_session"] = context["sessions"].last()
playrange_start = context["sessions"].last().timestamp_start.strftime("%b %Y")
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="")
request.session["return_path"] = request.path
return render(request, "view_game.html", context)