From 537debcdd00ddc5fbf151fece61897264aa3374a Mon Sep 17 00:00:00 2001 From: jsjiang Date: Fri, 1 Nov 2024 11:41:37 -0700 Subject: [PATCH 1/3] output queue name --- ezidapp/management/commands/proc-cleanup-async-queues_v2.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ezidapp/management/commands/proc-cleanup-async-queues_v2.py b/ezidapp/management/commands/proc-cleanup-async-queues_v2.py index 2b788551..7d52ad5c 100644 --- a/ezidapp/management/commands/proc-cleanup-async-queues_v2.py +++ b/ezidapp/management/commands/proc-cleanup-async-queues_v2.py @@ -196,8 +196,7 @@ def deleteRecord(self, queue, primary_key, record_type=None, identifier=None): try: # check if the record to be deleted is a refIdentifier record if (record_type is not None and record_type == 'refId'): - log.info(type(queue)) - log.info("Delete refId: " + str(primary_key)) + log.info(f"Delete from {queue.__name__} refId: " + str(primary_key)) with transaction.atomic(): obj = queue.objects.select_for_update().get(id=primary_key) obj.delete() From 6053b1c3cfde42e22088bceab9bdf0710625649c Mon Sep 17 00:00:00 2001 From: jsjiang Date: Fri, 1 Nov 2024 11:51:33 -0700 Subject: [PATCH 2/3] reset last_id for next time range --- ezidapp/management/commands/proc-cleanup-async-queues_v2.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ezidapp/management/commands/proc-cleanup-async-queues_v2.py b/ezidapp/management/commands/proc-cleanup-async-queues_v2.py index 7d52ad5c..c04fd1c0 100644 --- a/ezidapp/management/commands/proc-cleanup-async-queues_v2.py +++ b/ezidapp/management/commands/proc-cleanup-async-queues_v2.py @@ -173,8 +173,9 @@ def run(self): log.info(f"Finished - Checking ref Ids: {time_range_str}") exit() else: - log.info(f"Sleep {ASYNC_CLEANUP_SLEEP} seconds before processing next batch") + log.info(f"Sleep {ASYNC_CLEANUP_SLEEP} seconds before processing next time range.") self.sleep(ASYNC_CLEANUP_SLEEP) + last_id = 0 min_age_ts = max_age_ts max_age_ts = min_age_ts + ASYNC_CLEANUP_SLEEP time_range = Q(updateTime__gte=min_age_ts) & Q(updateTime__lte=max_age_ts) From a3440ea5edf1749e83274e566b22d2bb51dfc0ff Mon Sep 17 00:00:00 2001 From: jsjiang Date: Mon, 4 Nov 2024 09:44:59 -0800 Subject: [PATCH 3/3] reset time range for next batch --- ezidapp/management/commands/proc-cleanup-async-queues_v2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ezidapp/management/commands/proc-cleanup-async-queues_v2.py b/ezidapp/management/commands/proc-cleanup-async-queues_v2.py index c04fd1c0..85640407 100644 --- a/ezidapp/management/commands/proc-cleanup-async-queues_v2.py +++ b/ezidapp/management/commands/proc-cleanup-async-queues_v2.py @@ -177,7 +177,7 @@ def run(self): self.sleep(ASYNC_CLEANUP_SLEEP) last_id = 0 min_age_ts = max_age_ts - max_age_ts = min_age_ts + ASYNC_CLEANUP_SLEEP + max_age_ts = int(time.time()) - django.conf.settings.DAEMONS_EXPUNGE_MAX_AGE_SEC time_range = Q(updateTime__gte=min_age_ts) & Q(updateTime__lte=max_age_ts) time_range_str = f"updated between: {self.seconds_to_date(min_age_ts)} and {self.seconds_to_date(max_age_ts)}" else: