mirror of
https://github.com/pretix/pretix.git
synced 2026-05-04 15:04:03 +00:00
Orders API: Reduce query load imposed by ?pdf_data=true by multiple orders of magnitude
This commit is contained in:
@@ -36,10 +36,15 @@ def register_data(sender, **kwargs):
|
||||
|
||||
def get_answer(op, order, event, question_id):
|
||||
try:
|
||||
a = op.answers.get(question_id=question_id)
|
||||
if 'answers' in op._prefetched_objects_cache:
|
||||
a = [a for a in op.answers.all() if a.question_id == question_id][0]
|
||||
else:
|
||||
a = op.answers.get(question_id=question_id)
|
||||
return str(a).replace("\n", "<br/>\n")
|
||||
except QuestionAnswer.DoesNotExist:
|
||||
return ""
|
||||
except IndexError:
|
||||
return ""
|
||||
|
||||
|
||||
@receiver(layout_text_variables, dispatch_uid="pretix_ticketoutputpdf_layout_text_variables_questions")
|
||||
|
||||
Reference in New Issue
Block a user