Skip to content

Commit 1a47758

Browse files
committed
feat: use bulk updates in number assignment
1 parent 54fddd0 commit 1a47758

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

bullet/bullet_admin/views/teams.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,8 @@ def assign_numbers(self, force):
353353
for team in teams:
354354
if team.number is None:
355355
team.number = ideal_numbers.pop()
356-
team.save()
356+
357+
Team.objects.bulk_update(teams, ["number"])
357358

358359
@transaction.atomic
359360
def assign_symbols(self, force):
@@ -385,20 +386,21 @@ def assign_symbols(self, force):
385386
# the team should not have a symbol
386387
if school_counts[team.school_id] == 1 and team.in_school_symbol:
387388
team.in_school_symbol = None
388-
team.save()
389389

390390
# the team should have a symbol
391391
if school_counts[team.school_id] > 1 and not team.in_school_symbol:
392392
team.in_school_symbol = school_unused_symbols[team.school_id].pop()
393-
team.save()
393+
394+
Team.objects.bulk_update(teams, ["in_school_symbol"])
394395

395396
@transaction.atomic
396397
def assign_passwords(self):
397398
teams = Team.objects.competing().filter(venue=self.venue).order_by("id")
398399
for team in teams:
399400
if not team.online_password:
400401
team.generate_online_password()
401-
team.save()
402+
403+
Team.objects.bulk_update(teams, ["online_password"])
402404

403405
def post(self, request, *args, **kwargs):
404406
force = "force" in request.POST

0 commit comments

Comments
 (0)