Skip to content

Commit

Permalink
Added patch for leaderboard refresh. (#314)
Browse files Browse the repository at this point in the history
  • Loading branch information
mohitanand001 authored and Sean Auriti committed Jul 8, 2017
1 parent 46aac0d commit 353075d
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions website/management/commands/leaderboard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from django.core.management.base import BaseCommand, CommandError
from django.contrib.auth.models import User

from website.models import UserProfile, Issue

class Command(BaseCommand):
help = 'Update user based on number of bugs'

def handle(self, *args, **options):
all_user_prof = UserProfile.objects.all()
all_user = User.objects.all()
for user_ in all_user:
user_prof = UserProfile.objects.get(user=user_)
total_issues = Issue.objects.filter(user=user_).count()
if total_issues <=10:
user_prof.title=1
elif total_issues <=50:
user_prof.title = 2
elif total_issues <= 200:
user_prof.title = 3
else:
user_prof.title = 4

user_prof.save()

return str("All users updated.")

0 comments on commit 353075d

Please sign in to comment.