Skip to content

Commit

Permalink
Discord: Fix thanks leaderboard
Browse files Browse the repository at this point in the history
  • Loading branch information
ConnorNelson committed Oct 18, 2024
1 parent d24cab5 commit 018fb6e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dojo_plugin/api/v1/discord.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,13 @@ def get(self):
return {"success": False, "error": "Invalid start format"}, 400

score = db.func.count(db.distinct(db.func.concat(DiscordUserActivity.message_id, "-", DiscordUserActivity.source_user_id))).label("score")
leaderboard = (
leaderboard_query = (
db.session.query(DiscordUserActivity.user_id, score)
.filter(DiscordUserActivity.type == "thanks", DiscordUserActivity.message_timestamp >= start)
.group_by(DiscordUserActivity.user_id)
.order_by(score.desc())
.limit(20)
.all()
)
leaderboard = [dict(discord_id=discord_id, score=score) for discord_id, score in leaderboard_query]

return {"success": True, "leaderboard": leaderboard}, 200

0 comments on commit 018fb6e

Please sign in to comment.