Skip to content

Commit

Permalink
admin: Attempt to optimize matches admin
Browse files Browse the repository at this point in the history
  • Loading branch information
Aiq0 committed Jan 11, 2025
1 parent 9517c2f commit 72e5c7c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions web/proboj/matches/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@
class MatchBotInline(admin.TabularInline):
model = MatchBot

# select related bot, as it is fetched for each BotVersion
# (to retrieve BotVersion.__str__) and this is called for every
# match bot in match admin
def get_formset(self, request, obj=None, **kwargs):
formset = super(MatchBotInline, self).get_formset(request, obj, **kwargs)

queryset = formset.form.base_fields["bot_version"].queryset
queryset = queryset.select_related("bot")
formset.form.base_fields["bot_version"].queryset = queryset

return formset


@admin.action(description="Enqueue selected matches")
def enqueue_match(modeladmin, request, queryset):
Expand Down

0 comments on commit 72e5c7c

Please sign in to comment.