From a765fd8d00a051fd1f8dad7bbda2d51fd5847445 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Kucharczyk?= Date: Sun, 14 Jan 2024 17:04:06 +0100 Subject: [PATCH] More game overview optimizations --- games/templates/view_game.html | 2 +- games/views.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/games/templates/view_game.html b/games/templates/view_game.html index c8fb77a..ed8054d 100644 --- a/games/templates/view_game.html +++ b/games/templates/view_game.html @@ -57,7 +57,7 @@

Sessions - ({{ sessions.count }}) + ({{ session_count }}) {% url 'start_game_session' game.id as add_session_link %} {% include 'components/button.html' with title="Start new session" text="New" link=add_session_link %} and Notes ({{ sessions_with_notes_count }}) diff --git a/games/views.py b/games/views.py index 3ec5bf6..d8f145e 100644 --- a/games/views.py +++ b/games/views.py @@ -170,7 +170,9 @@ def view_game(request, game_id=None): .order_by("year_released") ) - sessions = Session.objects.filter(purchase__edition__game=game) + sessions = Session.objects.prefetch_related("device").filter( + purchase__edition__game=game + ) session_count = sessions.count() playrange_start = sessions.earliest().timestamp_start.strftime("%b %Y")