Orders API: Reduce query load imposed by ?pdf_data=true by multiple orders of magnitude

This commit is contained in:
Raphael Michel
2018-09-25 17:39:58 +02:00
parent abd679820f
commit feb262644e
4 changed files with 45 additions and 9 deletions

View File

@@ -161,7 +161,10 @@ DEFAULT_VARIABLES = OrderedDict((
"editor_sample": _("Addon 1\nAddon 2"),
"evaluate": lambda op, order, ev: "<br/>".join([
'{} - {}'.format(p.item, p.variation) if p.variation else str(p.item)
for p in op.addons.select_related('item', 'variation')
for p in (
op.addons.all() if 'addons' in op._prefetched_objects_cache
else op.addons.select_related('item', 'variation')
)
])
}),
("organizer", {