Skip to content

Commit

Permalink
Temp Fix to reset wharton caching for GSRs
Browse files Browse the repository at this point in the history
  • Loading branch information
vcai122 committed Oct 2, 2023
1 parent 29b580d commit f0cbfbc
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
27 changes: 27 additions & 0 deletions backend/gsr_booking/management/commands/reset_wharton_caching.py
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")
42 changes: 42 additions & 0 deletions k8s/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,48 @@ export class MyChart extends PennLabsChart {
cmd: ["python", "manage.py", "load_target_populations"],
env: [{ name: "DJANGO_SETTINGS_MODULE", value: "pennmobile.settings.production" }]
});

// TODO: remove this once we have a better way to do this
new CronJob(this, 'reset-wharton-caching-1', {
schedule: cronTime.everyYearIn(10, 2),
image: backendImage,
secret,
cmd: ["python", "manage.py", "reset_wharton_caching", "1"],
env: [{ name: "DJANGO_SETTINGS_MODULE", value: "pennmobile.settings.production" }]
});

new CronJob(this, 'reset-wharton-caching-2', {
schedule: cronTime.everyYearIn(10, 3),
image: backendImage,
secret,
cmd: ["python", "manage.py", "reset_wharton_caching", "2"],
env: [{ name: "DJANGO_SETTINGS_MODULE", value: "pennmobile.settings.production" }]
});

new CronJob(this, 'reset-wharton-caching-3', {
schedule: cronTime.everyYearIn(10, 4),
image: backendImage,
secret,
cmd: ["python", "manage.py", "reset_wharton_caching", "3"],
env: [{ name: "DJANGO_SETTINGS_MODULE", value: "pennmobile.settings.production" }]
});

new CronJob(this, 'reset-wharton-caching-4', {
schedule: cronTime.everyYearIn(10, 5),
image: backendImage,
secret,
cmd: ["python", "manage.py", "reset_wharton_caching", "4"],
env: [{ name: "DJANGO_SETTINGS_MODULE", value: "pennmobile.settings.production" }]
});

new CronJob(this, 'reset-wharton-caching-5', {
schedule: cronTime.everyYearIn(10, 6),
image: backendImage,
secret,
cmd: ["python", "manage.py", "reset_wharton_caching", "5"],
env: [{ name: "DJANGO_SETTINGS_MODULE", value: "pennmobile.settings.production" }]
});

}
}

Expand Down

0 comments on commit f0cbfbc

Please sign in to comment.