aboutsummaryrefslogtreecommitdiffstats
path: root/bot/seasons/christmas/adventofcode.py
diff options
context:
space:
mode:
authorGravatar sco1 <[email protected]>2018-12-05 14:20:23 -0500
committerGravatar sco1 <[email protected]>2018-12-05 14:20:23 -0500
commit5a793f8960e9774d5cfd5f5784c67e9338e26a08 (patch)
tree1b667fe746d169a5baaf101473c380994aaa5e87 /bot/seasons/christmas/adventofcode.py
parentMerge pull request #80 from scragly/season_improvements (diff)
Add daily summary statistics calculation
Frame stats command Remove "stats" adjacent aliases for existing commands to avoid confusion
Diffstat (limited to 'bot/seasons/christmas/adventofcode.py')
-rw-r--r--bot/seasons/christmas/adventofcode.py42
1 files changed, 40 insertions, 2 deletions
diff --git a/bot/seasons/christmas/adventofcode.py b/bot/seasons/christmas/adventofcode.py
index fcd3e171..4f993f6a 100644
--- a/bot/seasons/christmas/adventofcode.py
+++ b/bot/seasons/christmas/adventofcode.py
@@ -207,7 +207,7 @@ class AdventOfCode:
@adventofcode_group.command(
name="leaderboard",
- aliases=("board", "stats", "lb"),
+ aliases=("board", "lb"),
brief="Get a snapshot of the PyDis private AoC leaderboard",
)
async def aoc_leaderboard(self, ctx: commands.Context, number_of_people_to_display: int = 10):
@@ -248,8 +248,21 @@ class AdventOfCode:
)
@adventofcode_group.command(
+ name="stats",
+ aliases=('lbs', "privatestats"),
+ brief=("Get summary statistics for the PyDis private leaderboard")
+ )
+ async def private_leaderboard_stats(self, ctx: commands.Context):
+ """
+ Return an embed with the summary statistics for the PyDis private leaderboard
+
+ Embed will display the total members, and the number of users who have completed each day's puzzle
+ """
+ raise NotImplementedError
+
+ @adventofcode_group.command(
name="global",
- aliases=("globalstats", "globalboard", "gb"),
+ aliases=("globalboard", "gb"),
brief="Get a snapshot of the global AoC leaderboard",
)
async def global_leaderboard(self, ctx: commands.Context, number_of_people_to_display: int = 10):
@@ -461,6 +474,8 @@ class AocPrivateLeaderboard:
self._event_year = event_year
self.last_updated = datetime.utcnow()
+ self.daily_completion_summary = self.calculate_daily_completion()
+
def top_n(self, n: int = 10) -> dict:
"""
Return the top n participants on the leaderboard.
@@ -470,6 +485,29 @@ class AocPrivateLeaderboard:
return self.members[:n]
+ def calculate_daily_completion(self) -> List[tuple]:
+ """
+ Calculate member completion rates by day
+
+ Return a list of tuples for each day containing the number of users who completed each part
+ of the challenge
+ """
+
+ daily_member_completions = []
+ for day in range(25):
+ one_star_count = 0
+ two_star_count = 0
+ for member in self.members:
+ if member.starboard[day][1]:
+ one_star_count += 1
+ two_star_count += 1
+ elif member.starboard[day][0]:
+ one_star_count += 1
+ else:
+ daily_member_completions.append((one_star_count, two_star_count))
+
+ return(daily_member_completions)
+
@staticmethod
async def json_from_url(
leaderboard_id: int = AocConfig.leaderboard_id, year: int = AocConfig.year