diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2025-06-26 20:45:11 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2025-06-26 20:45:11 +0200 |
commit | 737587eda4391494b1c44caa5e21ad7c2ff9ef50 (patch) | |
tree | 5736c3f16c12f007e7961b88561d2364368b2276 /ishtar_common/models_common.py | |
parent | aab08f0337002bb90a002e22153f9fd68e1dd61d (diff) | |
download | Ishtar-737587eda4391494b1c44caa5e21ad7c2ff9ef50.tar.bz2 Ishtar-737587eda4391494b1c44caa5e21ad7c2ff9ef50.zip |
⚡️ imports: performance optimisations
Diffstat (limited to 'ishtar_common/models_common.py')
-rw-r--r-- | ishtar_common/models_common.py | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py index c623a0604..79aa66953 100644 --- a/ishtar_common/models_common.py +++ b/ishtar_common/models_common.py @@ -1051,7 +1051,8 @@ class FullSearch(models.Model): m2m_search_vector.key, config=m2m_search_vector.language ) ).values("search") - search_vectors.append(q.all()[0]["search"]) + if q.count(): + search_vectors.append(q.all()[0]["search"]) # int/float are not well managed by the SearchVector for int_search_vector in self.INT_SEARCH_VECTORS: @@ -1875,6 +1876,16 @@ class BaseHistorizedItem( self.fix_associated() return True + def no_post_process(self, history=False): + if not history: + self.skip_history_when_saving = True + self._cached_label_checked = True + self._post_saved_geo = True + self._external_id_checked = True + self._search_updated = True + self._no_move = True + self._no_down_model_update = True + class LightHistorizedItem(BaseHistorizedItem): history_date = models.DateTimeField(default=datetime.datetime.now) @@ -3284,15 +3295,6 @@ class MainItem(ShortMenuItem, SerializeItem, SheetItem): if hasattr(item, "main_geodata"): item.post_save_geo() - def no_post_process(self): - self.skip_history_when_saving = True - self._cached_label_checked = True - self._post_saved_geo = True - self._external_id_checked = True - self._search_updated = True - self._no_move = True - self._no_down_model_update = True - @classmethod def app_label(cls): return cls._meta.app_label |