From 2d5fbae2793435bdbbf62f2490459dbe828361e3 Mon Sep 17 00:00:00 2001 From: havk Date: Tue, 20 Jul 2021 04:38:45 +0200 Subject: [PATCH] Add sessions key to hits_per_day dict (#160) --- shynet/core/models.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/shynet/core/models.py b/shynet/core/models.py index f19cbaa..54f057e 100644 --- a/shynet/core/models.py +++ b/shynet/core/models.py @@ -292,7 +292,10 @@ class Service(models.Model): .order_by("date") ) for k in hits_per_day: - chart_data[k["date"]]["hits"] = k["count"] + if k["date"] not in chart_data: + chart_data[k["date"]] = {"hits": k["count"], "sessions": 0} + else: + chart_data[k["date"]]["hits"] = k["count"] for day_offset in range((end_time - start_time).days + 1): day = (start_time + timezone.timedelta(days=day_offset)).date()