Fix error when generating charts with less than 2 entries

This commit is contained in:
Lukáš Kucharczyk 2023-02-19 14:55:06 +01:00
parent 5e54871374
commit 376beea02f
1 changed files with 1 additions and 1 deletions

View File

@ -156,7 +156,7 @@ def list_sessions(
# cannot use dataset[0] here because that might be only partial QuerySet # cannot use dataset[0] here because that might be only partial QuerySet
context["last"] = Session.objects.all().order_by("timestamp_start").last() context["last"] = Session.objects.all().order_by("timestamp_start").last()
# charts are always oldest->newest # charts are always oldest->newest
if Session.objects.count() >= 2: if dataset.count() >= 2:
context["chart"] = playtime_over_time_chart(dataset.order_by("timestamp_start")) context["chart"] = playtime_over_time_chart(dataset.order_by("timestamp_start"))
return render(request, "list_sessions.html", context) return render(request, "list_sessions.html", context)