-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Temp Fix to reset wharton caching for GSRs
- Loading branch information
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
backend/gsr_booking/management/commands/reset_wharton_caching.py
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,27 @@ | ||
from django.core.management.base import BaseCommand | ||
|
||
from gsr_booking.models import GroupMembership | ||
|
||
|
||
groups = [ | ||
"a-d", # 4107 | ||
"e-j", # 3674 | ||
"k-n", # 3583 | ||
"o-s", # 2852 | ||
"t-z", # 2103 | ||
] | ||
|
||
|
||
class Command(BaseCommand): | ||
def add_arguments(self, parser): | ||
parser.add_argument("group", type=int) | ||
|
||
def handle(self, *args, **kwargs): | ||
group = kwargs["group"] | ||
if group not in range(1, 6): | ||
self.stdout.write("Error: fraction must be between 1 and 5") | ||
return | ||
GroupMembership.objects.filter( | ||
is_wharton=False, user__username__iregex=rf"^[{groups[group-1]}]" | ||
).update(is_wharton=None) | ||
self.stdout.write("Successfully reset Wharton caching") |
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