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/data_importer.py | |
parent | aab08f0337002bb90a002e22153f9fd68e1dd61d (diff) | |
download | Ishtar-737587eda4391494b1c44caa5e21ad7c2ff9ef50.tar.bz2 Ishtar-737587eda4391494b1c44caa5e21ad7c2ff9ef50.zip |
⚡️ imports: performance optimisations
Diffstat (limited to 'ishtar_common/data_importer.py')
-rw-r--r-- | ishtar_common/data_importer.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/ishtar_common/data_importer.py b/ishtar_common/data_importer.py index 7717c0e03..c239b20b4 100644 --- a/ishtar_common/data_importer.py +++ b/ishtar_common/data_importer.py @@ -945,6 +945,8 @@ class Importer(object): item = cls.objects.get(pk=pk) except cls.DoesNotExist: continue + if cls != self.OBJECT_CLS: + cls._no_down_model_update = True item._timestamp = self.timestamp item._queue = "low_priority" item.save() @@ -1186,6 +1188,8 @@ class Importer(object): def _create_item(self, cls, dct, idx_line): obj = cls(**dct) obj._no_post_save = True # delayed at the end of the import + if hasattr(obj, "no_post_process"): + obj.no_post_process(history=True) obj._queue = "low_priority" obj.save() self._add_to_post_save(cls, obj.pk, idx_line) @@ -1326,6 +1330,9 @@ class Importer(object): else: self.number_updated += 1 + if hasattr(obj, "no_post_process"): + obj.no_post_process(history=True) + if not created and "defaults" in data: for k in data["defaults"]: setattr(obj, k, data["defaults"][k]) @@ -1372,6 +1379,8 @@ class Importer(object): setattr(item, k, geodata[k]) item._timestamp = self.timestamp item._queue = "low_priority" + if hasattr(item, "no_post_process"): + item.no_post_process(history=True) item.save() else: item = GeoVectorData.objects.create(**geodata) @@ -1390,6 +1399,8 @@ class Importer(object): obj._no_move = True obj.skip_history_when_saving = True obj._queue = "low_priority" + if hasattr(obj, "no_post_process"): + obj.no_post_process(history=True) obj.save() n = datetime.datetime.now() @@ -1463,6 +1474,8 @@ class Importer(object): t_obj._no_post_save = True t_obj._timestamp = self.timestamp t_obj._queue = "low_priority" + if hasattr(t_obj, "no_post_process"): + t_obj.no_post_process(history=True) t_obj.save() self._add_to_post_save(t_obj.__class__, t_obj.pk, idx_line) if self.import_instance and hasattr(t_obj, "imports") and created: @@ -1805,6 +1818,8 @@ class Importer(object): if changed: v._timestamp = self.timestamp v._queue = "low_priority" + if hasattr(v, "no_post_process"): + v.no_post_process(history=True) v.save() for att, objs in m2m_m2ms: if type(objs) not in (list, tuple): @@ -2154,6 +2169,8 @@ class Importer(object): setattr(obj, k, updated_dct[k]) obj._timestamp = self.timestamp obj._queue = "low_priority" + if hasattr(obj, "no_post_process"): + obj.no_post_process(history=True) obj.save() if ( not self.simulate @@ -2224,6 +2241,8 @@ class Importer(object): try: v._timestamp = self.timestamp v._queue = "low_priority" + if hasattr(v, "no_post_process"): + v.no_post_process(history=True) v.save() except DatabaseError as import_error: msg = str(import_error) |