Skip to content

Commit

Permalink
Fix leaderboard info endpoint.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey committed Dec 20, 2023
1 parent b84e484 commit 4d90055
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions engineapi/engineapi/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,7 @@ def get_leaderboard_info(
version_number=version_number,
)

leaderboard = (
query = (
db_session.query(
Leaderboard.id,
Leaderboard.title,
Expand All @@ -1038,26 +1038,33 @@ def get_leaderboard_info(
func.max(LeaderboardScores.updated_at).label("last_update"),
)
.join(
LeaderboardScores,
LeaderboardScores.leaderboard_id == Leaderboard.id,
LeaderboardVersion,
and_(
LeaderboardVersion.leaderboard_id == Leaderboard.id,
LeaderboardVersion.published == True,
),
isouter=True,
)
.join(
LeaderboardVersion,
LeaderboardScores,
and_(
LeaderboardVersion.leaderboard_id == LeaderboardScores.leaderboard_id,
LeaderboardVersion.version_number
== LeaderboardScores.leaderboard_version_number,
LeaderboardScores.leaderboard_id == Leaderboard.id,
LeaderboardScores.leaderboard_version_number
== LeaderboardVersion.version_number,
),
isouter=True,
)
.filter(
LeaderboardVersion.published == True,
LeaderboardVersion.version_number == latest_version,
or_(
LeaderboardVersion.published == None,
LeaderboardVersion.version_number == latest_version,
)
)
.filter(Leaderboard.id == leaderboard_id)
.group_by(Leaderboard.id, Leaderboard.title, Leaderboard.description)
).one()
)

leaderboard = query.one()

return leaderboard

Expand Down

0 comments on commit 4d90055

Please sign in to comment.