-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add leaderboard and overview of achievements #3686
Conversation
ae41188
to
54f95ff
Compare
585c84e
to
9cb5d9c
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3686 +/- ##
==========================================
- Coverage 89.67% 89.66% -0.01%
==========================================
Files 703 707 +4
Lines 22536 22605 +69
==========================================
+ Hits 20209 20269 +60
- Misses 2327 2336 +9 ☔ View full report in Codecov by Sentry. |
9cb5d9c
to
0019f22
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this might become slow with all users in prod, but I'm not sure how to improve it...
de955c3
to
21c8732
Compare
0cb28b5
to
dbf9495
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good.
Pagination of the LeaderBoardViewSet.get_queryset
would be nice, but can be done in a later PR.
delta = 0.1 | ||
# Remember to update this rarity list when adding new achievement | ||
MAX_POSSIBLE_SCORE = sum( | ||
max(rarity_list) + 1 + (max(rarity_list) * delta) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this work? rarity_list
doesn't seem to be defined at this point
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is going to give you a runtime error. If this code works, it seems to be because of unintended behavior
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is apparently due to a quirk in python as the defenition depends on a dictionary that already exists it apparently works
value = rarity_list[achievement.level] | ||
score += value + 1 + (achievement.level * delta) | ||
|
||
return score if MAX_POSSIBLE_SCORE else 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not quite sure why the presence of MAX_POSSIBLE_SCORE
would matter here
lego/apps/users/models.py
Outdated
@@ -421,6 +422,12 @@ def delete(self, using=None, force=False): | |||
event.unregister(event.registrations.get(user=self)) | |||
super(User, self).delete(using=using, force=force) | |||
|
|||
def save(self, *args, **kwargs): | |||
from lego.apps.achievements.utils.calculation_utils import calculate_user_rank |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you educate me on the benefits of a late import like this? 👼
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to avoid a circular import it unfortunately has to be done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good.
Pagination of the LeaderBoardViewSet.get_queryset
would be nice, but can be done in a later PR.
e5a7c23
to
a9e1cde
Compare
a9e1cde
to
7c7f7ff
Compare
cf6e9c7
to
dc4eda2
Compare
No description provided.