From 66f6d4951bc7cd801757feca3b4a403ebedb2d64 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 26 Jun 2025 20:45:11 +0200 Subject: ⚡️ imports: performance optimisations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ishtar_common/models_common.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'ishtar_common/models_common.py') diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py index e749580f4..19d04ea17 100644 --- a/ishtar_common/models_common.py +++ b/ishtar_common/models_common.py @@ -1133,7 +1133,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: @@ -1950,6 +1951,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) @@ -3440,15 +3451,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 -- cgit v1.2.3