Skip to content

Commit b54e093

Browse files
committed
Make admin pages for cfbot branch and tasks fast
1 parent f0841dc commit b54e093

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

pgcommitfest/commitfest/admin.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,28 @@ class TagAdmin(admin.ModelAdmin):
6868
}
6969

7070

71+
class CfbotBranchAdmin(admin.ModelAdmin):
72+
# Without this the patch field is rendered as a dropdown, for which every
73+
# patch in the database gets fetched and rendered as an <option>. That
74+
# makes the page extremely slow to load. With raw_id_fields it's rendered
75+
# as a simple text input containing the patch id instead.
76+
raw_id_fields = ("patch",)
77+
78+
79+
class CfbotTaskAdmin(admin.ModelAdmin):
80+
# See CfbotBranchAdmin for why raw_id_fields is used here.
81+
raw_id_fields = ("patch",)
82+
83+
7184
admin.site.register(Committer, CommitterAdmin)
7285
admin.site.register(CommitFest)
7386
admin.site.register(Tag, TagAdmin)
7487
admin.site.register(Topic)
7588
admin.site.register(Patch, PatchAdmin)
7689
admin.site.register(PatchHistory)
7790
admin.site.register(TargetVersion)
78-
admin.site.register(CfbotBranch)
79-
admin.site.register(CfbotTask)
91+
admin.site.register(CfbotBranch, CfbotBranchAdmin)
92+
admin.site.register(CfbotTask, CfbotTaskAdmin)
8093

8194
admin.site.register(MailThread, MailThreadAdmin)
8295
admin.site.register(MailThreadAttachment, MailThreadAttachmentAdmin)

0 commit comments

Comments
 (0)