MCPcopy Create free account
hub / github.com/ImGoodBai/MapGoGoGo / leaderboard

Function leaderboard

backend/app/main.py:392–407  ·  view source on GitHub ↗
(challenge_id: str)

Source from the content-addressed store, hash-verified

390
391@app.get("/api/challenges/{challenge_id}/leaderboard")
392def leaderboard(challenge_id: str) -> dict:
393 with connect() as conn:
394 rows = conn.execute(
395 """
396 SELECT p.id, p.nickname, COUNT(u.cell_id) AS unlocked_cells,
397 MAX(u.created_at) AS last_unlocked_at
398 FROM user_unlocked_cells u
399 JOIN participants p ON p.id = u.participant_id
400 WHERE u.challenge_id = ?
401 GROUP BY p.id, p.nickname
402 ORDER BY unlocked_cells DESC, last_unlocked_at ASC
403 LIMIT 100
404 """,
405 (challenge_id,),
406 ).fetchall()
407 return {"leaderboard": [row_to_dict(row) for row in rows]}
408
409
410@app.post("/api/challenges/{challenge_id}/unlock")

Callers

nothing calls this directly

Calls 2

connectFunction · 0.85
row_to_dictFunction · 0.85

Tested by

no test coverage detected