From 296ee1376450adf58a040a9da816a100fa5d2ec9 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 12 Sep 2024 12:39:40 +0200 Subject: ⚡️ improve performance - external ID: prevent double save - user UPDATE query instead of save - remove dead code "BulkUpdatedItem" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- archaeological_context_records/models.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'archaeological_context_records/models.py') diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py index e13633d90..0ac13e43a 100644 --- a/archaeological_context_records/models.py +++ b/archaeological_context_records/models.py @@ -52,7 +52,6 @@ from ishtar_common.models import ( post_delete_record_relation, post_save_cache, ValueGetter, - BulkUpdatedItem, RelationItem, Town, get_current_profile, @@ -461,7 +460,6 @@ class GeographicSubTownItem(GeoItem): class ContextRecord( - BulkUpdatedItem, DocumentItem, BaseHistorizedItem, CompleteIdentifierItem, @@ -1286,8 +1284,15 @@ def context_record_post_save(sender, **kwargs): cached_label_changed(sender=sender, **kwargs) post_save_geo(sender=sender, **kwargs) instance = kwargs.get("instance", None) - if instance and instance.pk: - ContextRecordTree.update(instance.pk) + if not instance or not instance.pk: + return + ContextRecordTree.update(instance.pk) + BaseFind = apps.get_model("archaeological_finds", "BaseFind") + Find = apps.get_model("archaeological_finds", "Find") + for bf in instance.base_finds.all(): + cached_label_changed(BaseFind, instance=bf) + for f in bf.find.all(): + cached_label_changed(Find, instance=f) post_save.connect(context_record_post_save, sender=ContextRecord) -- cgit v1.2.3