Fix date range on game overview
This commit is contained in:
parent
760f12e6b1
commit
3e04ef2b83
|
@ -7,7 +7,7 @@
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="dark:text-white max-w-sm sm:max-w-xl lg:max-w-3xl mx-auto">
|
<div class="dark:text-white max-w-sm sm:max-w-xl lg:max-w-3xl mx-auto">
|
||||||
<h1 class="text-4xl">{{ game.name }} (#{{ game.pk }})</h1>
|
<h1 class="text-4xl">{{ game.name }} (#{{ game.pk }})</h1>
|
||||||
<h2 class="text-lg my-2 ml-2">{{ total_playtime }} ({{ first_session.timestamp_end | date:"M Y"}} — {{ first_session.timestamp_end | date:"M Y"}}) </h2>
|
<h2 class="text-lg my-2 ml-2">{{ total_playtime }} ({{ first_session.timestamp_end | date:"M Y"}} — {{ last_session.timestamp_end | date:"M Y"}}) </h2>
|
||||||
<hr class="border-slate-500">
|
<hr class="border-slate-500">
|
||||||
<h1 class="text-3xl mt-4 mb-1">Editions</h1>
|
<h1 class="text-3xl mt-4 mb-1">Editions</h1>
|
||||||
<ul>
|
<ul>
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
<h1 class="text-3xl mt-4 mb-1">Sessions</h1>
|
<h1 class="text-3xl mt-4 mb-1">Sessions</h1>
|
||||||
<ul>
|
<ul>
|
||||||
{% for session in sessions %}
|
{% for session in sessions %}
|
||||||
<li class="sm:pl-2">{{ session.timestamp_end | date:"d/m/Y" }} ({{ session.device.get_type_display | default:"Unknown" }}, {{ session.duration_formatted }})</li>
|
<li class="sm:pl-2">{{ session.timestamp_start | date:"d/m/Y" }} ({{ session.device.get_type_display | default:"Unknown" }}, {{ session.duration_formatted }})</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
|
@ -98,10 +98,15 @@ def view_game(request, game_id=None):
|
||||||
context["game"] = game
|
context["game"] = game
|
||||||
context["editions"] = Edition.objects.filter(game_id=game_id)
|
context["editions"] = Edition.objects.filter(game_id=game_id)
|
||||||
context["purchases"] = Purchase.objects.filter(edition__game_id=game_id)
|
context["purchases"] = Purchase.objects.filter(edition__game_id=game_id)
|
||||||
context["sessions"] = Session.objects.filter(purchase__edition__game_id=game_id)
|
context["sessions"] = Session.objects.filter(
|
||||||
|
purchase__edition__game_id=game_id
|
||||||
|
).order_by("-timestamp_start")
|
||||||
context["total_playtime"] = context["sessions"].total_duration()
|
context["total_playtime"] = context["sessions"].total_duration()
|
||||||
context["last_session"] = context["sessions"].last
|
# here first and last is flipped
|
||||||
context["first_session"] = context["sessions"].first
|
# 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()
|
||||||
return render(request, "view_game.html", context)
|
return render(request, "view_game.html", context)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue