diff options
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 |
commit | 62ebb037781a1df38191823cc44a06726bc28683 (patch) | |
tree | d4597cfe77cc7854749d41f980e2bde18b3134af /archaeological_warehouse/models.py | |
parent | 9c62a2b2019a0c30fadf7413652b8d0b1fc7f748 (diff) | |
download | Ishtar-62ebb037781a1df38191823cc44a06726bc28683.tar.bz2 Ishtar-62ebb037781a1df38191823cc44a06726bc28683.zip |
Improve document generation perf
Diffstat (limited to 'archaeological_warehouse/models.py')
-rw-r--r-- | archaeological_warehouse/models.py | 12 |
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 |