Fix errors with empty database
This commit is contained in:
parent
4e67735de8
commit
89be0c031b
|
@ -1,4 +1,5 @@
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
* Fix errors with empty database
|
||||||
* Fix negative playtimes being considered positive
|
* Fix negative playtimes being considered positive
|
||||||
* Add %d for days to common.util.time.format_duration
|
* Add %d for days to common.util.time.format_duration
|
||||||
* Set up tests, add tests for common.util.time
|
* Set up tests, add tests for common.util.time
|
||||||
|
|
|
@ -104,12 +104,12 @@ def add_platform(request):
|
||||||
def index(request):
|
def index(request):
|
||||||
context = {}
|
context = {}
|
||||||
if Session.objects.count() == 0:
|
if Session.objects.count() == 0:
|
||||||
duration_value = 0
|
duration: str = ""
|
||||||
else:
|
else:
|
||||||
result = Session.objects.all().aggregate(Sum("duration_calculated"))
|
result = Session.objects.all().aggregate(Sum("duration_calculated"))
|
||||||
context["total_duration"] = format_duration(
|
duration = format_duration(
|
||||||
result["duration_calculated__sum"], "%H hours %m minutes"
|
result["duration_calculated__sum"], "%H hours %m minutes"
|
||||||
)
|
)
|
||||||
context["total_duration"] = duration_value
|
context["total_duration"] = duration
|
||||||
context["title"] = "Index"
|
context["title"] = "Index"
|
||||||
return render(request, "index.html", context)
|
return render(request, "index.html", context)
|
||||||
|
|
Loading…
Reference in New Issue