Fix date range on game overview
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
e3ee832d3f
commit
d2a9630b04
|
@ -7,7 +7,7 @@
|
|||
{% block content %}
|
||||
<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>
|
||||
<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">
|
||||
<h1 class="text-3xl mt-4 mb-1">Editions</h1>
|
||||
<ul>
|
||||
|
@ -33,7 +33,7 @@
|
|||
<h1 class="text-3xl mt-4 mb-1">Sessions</h1>
|
||||
<ul>
|
||||
{% 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 %}
|
||||
</ul>
|
||||
|
||||
|
|
|
@ -98,10 +98,15 @@ def view_game(request, game_id=None):
|
|||
context["game"] = game
|
||||
context["editions"] = Edition.objects.filter(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["last_session"] = context["sessions"].last
|
||||
context["first_session"] = context["sessions"].first
|
||||
# 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()
|
||||
return render(request, "view_game.html", context)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue