diff --git a/games/templates/view_game.html b/games/templates/view_game.html
index 2667a93..1e2a210 100644
--- a/games/templates/view_game.html
+++ b/games/templates/view_game.html
@@ -7,7 +7,7 @@
{% block content %}
{{ game.name }} (#{{ game.pk }})
-
{{ total_playtime }} ({{ first_session.timestamp_end | date:"M Y"}} — {{ first_session.timestamp_end | date:"M Y"}})
+
{{ total_playtime }} ({{ first_session.timestamp_end | date:"M Y"}} — {{ last_session.timestamp_end | date:"M Y"}})
Editions
@@ -33,7 +33,7 @@
Sessions
{% for session in sessions %}
- - {{ session.timestamp_end | date:"d/m/Y" }} ({{ session.device.get_type_display | default:"Unknown" }}, {{ session.duration_formatted }})
+ - {{ session.timestamp_start | date:"d/m/Y" }} ({{ session.device.get_type_display | default:"Unknown" }}, {{ session.duration_formatted }})
{% endfor %}
diff --git a/games/views.py b/games/views.py
index 6c70d9f..4c111ac 100644
--- a/games/views.py
+++ b/games/views.py
@@ -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)