From ddb3dcf00573dd46e260ac2e39bfc09e68e68e44 Mon Sep 17 00:00:00 2001 From: Sebastiaan Zeeff Date: Tue, 1 Dec 2020 18:33:11 +0100 Subject: Fix daily stats by converting day, star to str The daily stats function contained a bug that prevented it from working correctly. The reason was that I was looking for `int` keys where the actual keys were strings. I now make sure to create a `str` from the `int` I get back from `range`. --- bot/exts/christmas/advent_of_code/_helpers.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'bot') diff --git a/bot/exts/christmas/advent_of_code/_helpers.py b/bot/exts/christmas/advent_of_code/_helpers.py index e84348cb..f4a20955 100644 --- a/bot/exts/christmas/advent_of_code/_helpers.py +++ b/bot/exts/christmas/advent_of_code/_helpers.py @@ -123,8 +123,9 @@ def _parse_raw_leaderboard_data(raw_leaderboard_data: dict) -> dict: # Create summary stats for the stars completed for each day of the event. daily_stats = {} for day in range(1, 26): - star_one = len(star_results.get((day, 1), [])) - star_two = len(star_results.get((day, 1), [])) + day = str(day) + star_one = len(star_results.get((day, "1"), [])) + star_two = len(star_results.get((day, "2"), [])) # By using a dictionary instead of namedtuple here, we can serialize # this data to JSON in order to cache it in Redis. daily_stats[day] = {"star_one": star_one, "star_two": star_two} -- cgit v1.2.3