Closed TimJentzsch closed 2 years ago
It might be possible to do this by putting the data in a dictionary first. https://stackoverflow.com/questions/52735708/proper-way-to-annotate-a-rank-field-for-a-queryset But this seems horribly inefficient to me
Apparently, window expressions are not supported by the test environment so I'll have to find an alternative.
Relevant issue: Closes #175
Description:
This adds an additional
submission/leaderboard
endpoint that can be used to get a users rank according to their gamma. This is the last big change needed to implement the rest of the important Buttercup commands.The endpoints take the parameters
user_id
to specify the user that the leaderboard is centered on as wel astop_count
,above_count
andbelow_count
to control how many ranks are returned.The response looks like this:
Where every item in
top
,above
andbelow
looks like theuser
item.The submissions that the ranks are calculated on can be filtered as usual.
Future Work
After a lot of research, I was not able to find an efficient implementation to model the leaderboard. This is mainly due to two reasons: (a)
gamma
is a computed property and cannot be accessed directly and (b) theDenseRank
annotation gets destroyed when the queryset is filtered further.The current implementation creates the rank and data of every user at some point, so it scales poorly the more users we get. I am assuming that we don't have enough users yet for this to be a problem, but it would be nice if we find a better implementation in the long run.
Checklist: