Skip to content

Commit

Permalink
Update backfilljsonmods command for score filters
Browse files Browse the repository at this point in the history
  • Loading branch information
Syriiin committed Dec 21, 2024
1 parent 6859974 commit 05226f8
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions profiles/management/commands/backfilljsonmods.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 05226f8

Please sign in to comment.