Scoreboard optimizations (#1476)

* Add speed improvements for /api/v1/scoreboard/top/<count>

* Update CHANGELOG

* Fix typo

* Switch back to processing solves and awards seperately

* Fix typo
This commit is contained in:
Kevin Chung
2020-06-04 16:54:45 -04:00
committed by GitHub
parent 56d7b6d6d0
commit 8b6e91f76c

View File

@@ -122,7 +122,6 @@ class ScoreboardDetail(Resource):
awards = awards.all()
# Build a mapping of accounts to their solves and awards
solves = solves + awards
solves_mapper = defaultdict(list)
for solve in solves:
solves_mapper[solve.account_id].append(
@@ -136,6 +135,18 @@ class ScoreboardDetail(Resource):
}
)
for award in awards:
solves_mapper[award.account_id].append(
{
"challenge_id": None,
"account_id": award.account_id,
"team_id": award.team_id,
"user_id": award.user_id,
"value": award.value,
"date": isoformat(award.date),
}
)
# Sort all solves by date
for team_id in solves_mapper:
solves_mapper[team_id] = sorted(