-
-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added patch for leaderboard refresh. (#314)
- Loading branch information
1 parent
46aac0d
commit 353075d
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.") |