Skip to content

Commit

Permalink
[frontend/statistics] Fixing missing timezone in datetime key
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
AlexandreDoneux committed Jan 26, 2024
1 parent 1639ec5 commit 55b1d70
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion inginious/frontend/pages/course_admin/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down

0 comments on commit 55b1d70

Please sign in to comment.