From 5d4f35da2ef160d7cb232951680ad0d9f51de59c Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Mon, 2 Dec 2024 17:58:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=B8=85=E9=99=A4=E5=90=8E=EF=BC=8C=E5=AF=B9?= =?UTF-8?q?=E8=AF=9D=E4=B8=AD=E7=9A=84=E6=96=87=E4=BB=B6=E5=9C=A8file?= =?UTF-8?q?=E8=A1=A8=E4=B8=AD=E6=B2=A1=E5=88=A0=E6=8E=89=E7=9A=84=E7=BC=BA?= =?UTF-8?q?=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1049852 --user=王孝刚 【应用编排】应用日志清除后,对话中的文件在file表中没删掉 https://www.tapd.cn/57709429/s/1622739 --- apps/common/job/clean_chat_job.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/common/job/clean_chat_job.py b/apps/common/job/clean_chat_job.py index d42c39982..778b8a8dc 100644 --- a/apps/common/job/clean_chat_job.py +++ b/apps/common/job/clean_chat_job.py @@ -39,11 +39,12 @@ def clean_chat_log_job(): with transaction.atomic(): logs_to_delete = Chat.objects.filter(query_conditions).values_list('id', flat=True)[:batch_size] count = logs_to_delete.count() + logs_to_delete_str = [str(uuid) for uuid in logs_to_delete] if count == 0: break deleted_count, _ = Chat.objects.filter(id__in=logs_to_delete).delete() # 删除对应的文件 - File.objects.filter(meta__chat_id__in=[str(uuid) for uuid in logs_to_delete]).delete() + File.objects.filter(meta__chat_id__in=logs_to_delete_str).delete() if deleted_count < batch_size: break @@ -57,6 +58,6 @@ def run(): existing_job = scheduler.get_job(job_id='clean_chat_log') if existing_job is not None: existing_job.remove() - scheduler.add_job(clean_chat_log_job, 'cron', hour='0', minute='5', id='clean_chat_log') + scheduler.add_job(clean_chat_log_job, 'cron', minute='*/5', id='clean_chat_log') finally: lock.un_lock('clean_chat_log_job')