Add default 0 hits to chart_data (#195)

This commit is contained in:
havk 2022-01-11 23:16:49 +01:00 committed by GitHub
parent 6032b9f4ee
commit f6188a8bd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -256,7 +256,8 @@ class Service(models.Model):
.order_by("hour")
)
chart_data = {
k["hour"]: {"sessions": k["count"]} for k in sessions_per_hour
k["hour"]: {"sessions": k["count"], "hits": 0}
for k in sessions_per_hour
}
hits_per_hour = (
hits.annotate(hour=TruncHour("start_time"))
@ -284,7 +285,9 @@ class Service(models.Model):
.annotate(count=models.Count("uuid"))
.order_by("date")
)
chart_data = {k["date"]: {"sessions": k["count"]} for k in sessions_per_day}
chart_data = {
k["date"]: {"sessions": k["count"], "hits": 0} for k in sessions_per_day
}
hits_per_day = (
hits.annotate(date=TruncDate("start_time"))
.values("date")