diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2023-11-13 18:55:30 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2023-11-14 16:57:37 +0100 |
commit | d0d146cc099bfe2d58a8c8ec6e57096661d1fdcb (patch) | |
tree | 1007a19ed094bb463a9234909d84412a379a3c9c /ishtar_common/data_importer.py | |
parent | 1d1fd6c794c8ca8e758fc416b43e0f881136057f (diff) | |
download | Ishtar-d0d146cc099bfe2d58a8c8ec6e57096661d1fdcb.tar.bz2 Ishtar-d0d146cc099bfe2d58a8c8ec6e57096661d1fdcb.zip |
⚡️ improve parcel post-treatments - add timestamp to prevent multiple geo and cached_label edition
Diffstat (limited to 'ishtar_common/data_importer.py')
-rw-r--r-- | ishtar_common/data_importer.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/ishtar_common/data_importer.py b/ishtar_common/data_importer.py index 8c46cadb6..0f447f957 100644 --- a/ishtar_common/data_importer.py +++ b/ishtar_common/data_importer.py @@ -873,12 +873,14 @@ class Importer(object): self.import_instance.state = "PP" self.import_instance.imported_line_numbers = "" self.import_instance.save() + self.timestamp = int(datetime.datetime.now().timestamp()) for cls_pk, idx_line in self.post_save_items.items(): if self.import_instance and not self.line_to_process: self.import_instance.add_imported_line(idx_line) cls, pk = cls_pk # force django based post-processing for the item item = cls.objects.get(pk=pk) + item._timestamp = self.timestamp item.save() if hasattr(item, "RELATED_POST_PROCESS"): for related_key in item.RELATED_POST_PROCESS: @@ -892,6 +894,7 @@ class Importer(object): for cls, pk in related_list.keys(): try: item = cls.objects.get(pk=pk) + item._timestamp = self.timestamp item.save() if hasattr(item, "fix"): # post save/m2m specific fix @@ -1105,6 +1108,7 @@ class Importer(object): return obj def _line_processing(self, idx_line, line): + self.timestamp = int(datetime.datetime.now().timestamp()) for item in self.to_be_close: item.close() self.to_be_close = [] @@ -1212,6 +1216,7 @@ class Importer(object): for k in data["defaults"]: setattr(obj, k, data["defaults"][k]) obj._no_post_save = True + obj._timestamp = self.timestamp obj.save() self._add_to_post_save(obj.__class__, obj.pk, idx_line) @@ -1250,6 +1255,7 @@ class Importer(object): if item: for k in geodata: setattr(item, k, geodata[k]) + item._timestamp = self.timestamp item.save() else: item = GeoVectorData.objects.create(**geodata) @@ -1260,6 +1266,7 @@ class Importer(object): if self.import_instance and created: item.imports.add(self.import_instance) if self.MAIN_GEO: + obj._timestamp = self.timestamp obj.main_geodata = item obj._post_saved_geo = True obj._no_move = True @@ -1335,6 +1342,7 @@ class Importer(object): for k in data["defaults"]: setattr(t_obj, k, data["defaults"][k]) t_obj._no_post_save = True + t_obj._timestamp = self.timestamp 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: @@ -1674,6 +1682,7 @@ class Importer(object): changed = True setattr(v, k, extra_fields[k]) if changed: + v._timestamp = self.timestamp v.save() for att, objs in m2m_m2ms: if type(objs) not in (list, tuple): @@ -2022,6 +2031,7 @@ class Importer(object): else: for k in updated_dct: setattr(obj, k, updated_dct[k]) + obj._timestamp = self.timestamp obj.save() if ( not self.simulate @@ -2090,6 +2100,7 @@ class Importer(object): self._add_to_post_save(v.__class__, v.pk, idx_line) v._no_post_save = True try: + v._timestamp = self.timestamp v.save() except DatabaseError as e: raise IntegrityError(e.message) |