Skip to content
This repository has been archived by the owner on Oct 7, 2021. It is now read-only.

Efficient Karma Leaderboard #87

Open
mitchdowney opened this issue Jul 4, 2014 · 0 comments
Open

Efficient Karma Leaderboard #87

mitchdowney opened this issue Jul 4, 2014 · 0 comments

Comments

@mitchdowney
Copy link
Member

Karma Leaderboard in home.py (this is repeated in podcast.py, episode.py, quote.py, and user.py)

Karma Leaderboard in models.py

Current implementation, will not scale for more users:

class HomeQuoteListView(ListView):
    ...
    all_karma_leaders = sorted(User.objects.all(), key = lambda u: u.userprofile.leaderboard_karma_total, reverse=True)

    # take only the top 5 karma_leaders
    all_karma_leaders = all_karma_leaders[:5]

    # remove the users who have submitted 0 quotes
    # they may not want to have their username public
    all_karma_leaders = [i for i in all_karma_leaders if i.userprofile.leaderboard_karma_total != None]

    context['karma_leaders'] = all_karma_leaders
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant