From 8ba5344a4d057aa5d12fa43f917a28388b667c32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Kucharczyk?= Date: Mon, 18 Sep 2023 19:37:42 +0200 Subject: [PATCH] Fix bug when filtering only manual sessions (#51) --- CHANGELOG.md | 1 + games/templates/list_sessions.html | 2 +- games/views.py | 5 +++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ce9127..2a9af3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ * Improve form appearance * Add helper buttons next to datime fields * Change recent session view to current year instead of last 30 days +* Fix bug when filtering only manual sessions (https://git.kucharczyk.xyz/lukas/timetracker/issues/51) ## 1.0.3 / 2023-02-20 17:16+01:00 diff --git a/games/templates/list_sessions.html b/games/templates/list_sessions.html index 1777afb..54af222 100644 --- a/games/templates/list_sessions.html +++ b/games/templates/list_sessions.html @@ -6,7 +6,7 @@ {% block content %}
- {% if dataset.count >= 2 %} + {% if chart %} {% endif %} {% if dataset.count >= 1 %} diff --git a/games/views.py b/games/views.py index ea362b8..c3b2a8d 100644 --- a/games/views.py +++ b/games/views.py @@ -181,8 +181,9 @@ def list_sessions( context["dataset"] = dataset # cannot use dataset[0] here because that might be only partial QuerySet context["last"] = Session.objects.all().order_by("timestamp_start").last() - # charts are always oldest->newest - if dataset.count() >= 2: + # only if 2 or more non-manual sessions exist + if dataset.filter(timestamp_end__isnull=False).count() >= 2: + # charts are always oldest->newest context["chart"] = playtime_over_time_chart(dataset.order_by("timestamp_start")) return render(request, "list_sessions.html", context)