From 7ec930f5a7d5750893e63abc87971a47d366dc4b Mon Sep 17 00:00:00 2001 From: helllllllder Date: Wed, 17 Nov 2021 10:26:37 -0300 Subject: [PATCH 1/2] add RepositoryNLPLogDocument delete on delete_nlp_logs task and deactivate delete signal handlers in CelerySignalProcessor --- bothub/common/signals.py | 6 ++++++ bothub/common/tasks.py | 2 ++ 2 files changed, 8 insertions(+) diff --git a/bothub/common/signals.py b/bothub/common/signals.py index 3d7ef531..421ec464 100644 --- a/bothub/common/signals.py +++ b/bothub/common/signals.py @@ -15,3 +15,9 @@ def handle_save(self, sender, instance, **kwargs): "es_handle_save", args=[instance.pk, app_label, model_name] ) ) + + def handle_pre_delete(self, sender, instance, **kwargs): + pass + + def handle_delete(self, sender, instance, **kwargs): + pass diff --git a/bothub/common/tasks.py b/bothub/common/tasks.py index 1f45ef1d..61a5ace2 100644 --- a/bothub/common/tasks.py +++ b/bothub/common/tasks.py @@ -14,6 +14,7 @@ from bothub import translate from bothub.api.grpc.connect_grpc_client import ConnectGRPCClient from bothub.celery import app +from bothub.common.documents import RepositoryNLPLogDocument from bothub.common.models import ( RepositoryQueueTask, RepositoryReports, @@ -270,6 +271,7 @@ def delete_nlp_logs(): max_id = batch[-1].id with transaction.atomic(): for log in batch: + RepositoryNLPLogDocument.search().query("match", pk=log.pk).delete() log.delete() num_updated += len(batch) From 835f19d83b53bd376c71e23f0a496bc2fe110e1c Mon Sep 17 00:00:00 2001 From: helllllllder Date: Wed, 17 Nov 2021 11:07:07 -0300 Subject: [PATCH 2/2] comment signals --- bothub/common/signals.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bothub/common/signals.py b/bothub/common/signals.py index 421ec464..34bc5b06 100644 --- a/bothub/common/signals.py +++ b/bothub/common/signals.py @@ -17,7 +17,13 @@ def handle_save(self, sender, instance, **kwargs): ) def handle_pre_delete(self, sender, instance, **kwargs): + """ + Logs deletions are now handled in delete_nlp_logs task + """ pass def handle_delete(self, sender, instance, **kwargs): + """ + Logs deletions are now handled in delete_nlp_logs task + """ pass