Skip to content

Commit

Permalink
fix: SQL queries not working
Browse files Browse the repository at this point in the history
  • Loading branch information
pesaventofilippo committed Nov 22, 2024
1 parent 5784623 commit 1a60ebc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,13 @@ async def leaderboardOre(filter: str="month") -> dict:
else:
filter = "all" # default

ore = select((p.email, sum(utils.timedelta_to_hours(p.duration))) for p in presenze).group_by(PresenzaLab.email)
ore = sorted(ore, key=lambda x: x[1], reverse=True)
ore = {}
for p in presenze:
if p.email not in ore:
ore[p.email] = 0
ore[p.email] += utils.timedelta_to_hours(p.duration)
ore = dict(sorted(ore.items(), key=lambda item: item[1], reverse=True))

return {
"leaderboard": ore,
"filter": filter
Expand Down

0 comments on commit 1a60ebc

Please sign in to comment.