summaryrefslogtreecommitdiff
path: root/archaeological_warehouse
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2021-02-16 19:44:31 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2021-02-28 12:15:24 +0100
commit4640d3649bd73b62dd2b1c301f7f1ebacba8fe4f (patch)
treed4597cfe77cc7854749d41f980e2bde18b3134af /archaeological_warehouse
parent06790f9bb9dc079d170a30ab10414f790e97edc0 (diff)
downloadIshtar-4640d3649bd73b62dd2b1c301f7f1ebacba8fe4f.tar.bz2
Ishtar-4640d3649bd73b62dd2b1c301f7f1ebacba8fe4f.zip
Improve document generation perf
Diffstat (limited to 'archaeological_warehouse')
-rw-r--r--archaeological_warehouse/models.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py
index 06c7cdcd8..cb144270b 100644
--- a/archaeological_warehouse/models.py
+++ b/archaeological_warehouse/models.py
@@ -651,6 +651,9 @@ class Container(DocumentItem, Merge, LightHistorizedItem,
STATISTIC_MODALITIES = [
key for key, lbl in STATISTIC_MODALITIES_OPTIONS.items()]
+ GET_VALUES_EXCLUDE_FIELDS = ValueGetter.GET_VALUES_EXCLUDE_FIELDS + [
+ "inside_container", "parent"]
+
# search parameters
EXTRA_REQUEST_KEYS = {
'location': 'location__pk',
@@ -1341,16 +1344,17 @@ class Container(DocumentItem, Merge, LightHistorizedItem,
def get_values(self, prefix='', no_values=False, filtr=None, **kwargs):
values = super(Container, self).get_values(
prefix=prefix, no_values=no_values, filtr=filtr, **kwargs)
- if (not filtr or prefix + 'finds' in filtr) and (
- not prefix.startswith("container_") and not
- prefix.startswith("container_ref_")):
+ from_find = prefix.startswith("container_") or \
+ prefix.startswith("container_ref_")
+ if (not filtr or prefix + 'finds' in filtr) and not from_find:
kwargs["exclude"] = [prefix + "container", prefix + "container_ref"]
# prevent recursive call
values[prefix + 'finds'] = [
f.get_values(
prefix=prefix, no_values=True, filtr=None, **kwargs)
for f in self.finds.distinct().all()]
- if (not filtr or prefix + 'operation' in filtr or
+ if not from_find and (
+ not filtr or prefix + 'operation' in filtr or
prefix + "context_record" in filtr) and self.finds.count():
# assume that only one operation is in this container
# you should know what you are doing when using theses variables