From 05226f8fd54e1251ad2372cfec05bb608df88826 Mon Sep 17 00:00:00 2001 From: Samuel Cattini-Schultz Date: Sat, 21 Dec 2024 14:55:13 +1100 Subject: [PATCH] Update backfilljsonmods command for score filters --- .../management/commands/backfilljsonmods.py | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/profiles/management/commands/backfilljsonmods.py b/profiles/management/commands/backfilljsonmods.py index 16b9e39..46a1ce5 100644 --- a/profiles/management/commands/backfilljsonmods.py +++ b/profiles/management/commands/backfilljsonmods.py @@ -1,22 +1,20 @@ from django.core.management.base import BaseCommand -from django.core.paginator import Paginator from tqdm import tqdm from common.osu.utils import get_json_mods -from profiles.models import Score +from profiles.models import ScoreFilter class Command(BaseCommand): - help = "Generates json mods for stable scores from legacy attributes" + help = "Generates json mods for all ScoreFilters" def handle(self, *args, **options): - scores = Score.objects.filter(is_stable=True).order_by("id") - paginator = Paginator(scores, per_page=2000) - - with tqdm(total=scores.count(), smoothing=0) as pbar: - for page in paginator: - for score in page: - score.mods_json = get_json_mods(score.mods, score.is_stable) - pbar.update() - - Score.objects.bulk_update(page, ["mods_json"]) + score_filters = ScoreFilter.objects.all() + for score_filter in tqdm(score_filters): + score_filter.required_mods_json = get_json_mods( + score_filter.required_mods, False + ) + score_filter.disqualified_mods_json = get_json_mods( + score_filter.disqualified_mods, False + ) + score_filter.save()