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

Added patch for leaderboard refresh. #314

Merged
merged 1 commit into from
Jul 8, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.")