From d2ca7db7aa68508b476c281d77544f14490041d8 Mon Sep 17 00:00:00 2001 From: Luca Date: Mon, 18 Dec 2023 02:23:44 +0100 Subject: [PATCH] feat(export): sort submissions and optimize query --- pretalx_musicrate/__init__.py | 2 +- pretalx_musicrate/views.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/pretalx_musicrate/__init__.py b/pretalx_musicrate/__init__.py index 3e2f46a..61fb31c 100644 --- a/pretalx_musicrate/__init__.py +++ b/pretalx_musicrate/__init__.py @@ -1 +1 @@ -__version__ = "0.9.0" +__version__ = "0.10.0" diff --git a/pretalx_musicrate/views.py b/pretalx_musicrate/views.py index 40c9424..43829cf 100644 --- a/pretalx_musicrate/views.py +++ b/pretalx_musicrate/views.py @@ -397,8 +397,14 @@ class ExportView(EventPermissionRequired, View): genre_question = request.event.pretalx_musicrate_settings.genre_question origin_question = request.event.pretalx_musicrate_settings.origin_question jurors = request.event.jurors.order_by("token") - for submission in request.event.submissions.prefetch_related("answers").filter( - submission_type__in=request.event.pretalx_musicrate_settings.submission_types.all() + for submission in ( + request.event.submissions.prefetch_related("answers") + .select_related("submission_type") + .filter( + submission_type__in=request.event.pretalx_musicrate_settings.submission_types.all() + ) + .only("title", "submission_type__name") + .order_by("created") ): submission_info = [submission.title, submission.submission_type.name] if genre_question is not None: