From 55b1d70b0d387db153dc934d4a69e1a55cca41f8 Mon Sep 17 00:00:00 2001 From: AlexandreDoneux <94830560+AlexandreDoneux@users.noreply.github.com> Date: Thu, 25 Jan 2024 14:34:49 +0100 Subject: [PATCH] [frontend/statistics] Fixing missing timezone in datetime key Using datetime objects as dictionnary keys will change depending on if a timezone was given. If a timezone is given the key will have an offset in addition to the date and time. In our case, adding the utc timezone to the c key solves the problem. --- inginious/frontend/pages/course_admin/statistics.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inginious/frontend/pages/course_admin/statistics.py b/inginious/frontend/pages/course_admin/statistics.py index 032bee3f8..75906da70 100644 --- a/inginious/frontend/pages/course_admin/statistics.py +++ b/inginious/frontend/pages/course_admin/statistics.py @@ -95,7 +95,7 @@ def _graph_stats(self, daterange, filter, limit): cur += increment for entry in stats_graph: - c = datetime(entry["_id"]["year"], entry["_id"]["month"], entry["_id"]["day"], 0 if method == "day" else entry["_id"]["hour"]) + c = datetime(entry["_id"]["year"], entry["_id"]["month"], entry["_id"]["day"], 0 if method == "day" else entry["_id"]["hour"], tzinfo=timezone.utc) all_submissions[c] += entry["submissions"] valid_submissions[c] += entry["validSubmissions"]