Skip to content
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

update: add leaderboard apis #452

Merged
merged 4 commits into from
Nov 23, 2023
Merged

Conversation

Ali-Salman29
Copy link

@Ali-Salman29 Ali-Salman29 commented Nov 20, 2023

Description: The PR contains APIs for leaderboard customizations

Copy link

@ziafazal ziafazal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ali-Salman29 thanks for creating this PR. I have added my feedback.

model = User
fields = ('username', 'name')

def to_representation(self, instance):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think its good idea to override to_representation for populating profile_image_url field I think you should create a field profile_image_url in serializer and then write get_profile_image_url method to populate it.

score = serializers.IntegerField()
badges = BadgeAssertionSerializer(many=True)

def to_representation(self, instance):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unable to understand the purpose of this to_representation override. Could you please explain?

course_badge_score = LeaderboardConfiguration.COURSE_BADGE_SCORE
event_badge_score = LeaderboardConfiguration.EVENT_BADGE_SCORE

leaderboard_data = (

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems very compute intensive query it might not work with large dataset. can we pre compute these on badge generation events to avoid this query scanning complete badge table?

@Ali-Salman29 Ali-Salman29 force-pushed the alisalman/leaderboard-apis branch from c89e6ee to d561d96 Compare November 20, 2023 12:57
@Ali-Salman29 Ali-Salman29 force-pushed the alisalman/leaderboard-apis branch from d561d96 to f7de918 Compare November 20, 2023 13:03
Copy link

@ziafazal ziafazal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ali-Salman29 overall looks good just remove the handler which updates leaderboard on configuration change and rely on management commands since we are not expecting the configuration to be changed too frequently.



@receiver(post_save, sender=LeaderboardConfiguration)
def update_leaderboard_scores(sender, instance, **kwargs):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should update leaderboard entries when configuration is changed. It can be very time consuming task and should be done via management command as you have created one below.

@Ali-Salman29 Ali-Salman29 merged this pull request into sdaia-dev Nov 23, 2023
8 of 40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants