Skip to content

Commit 4cc84a6

Browse files
committed
fix: 修复应用日志清除后,对话中的文件在file表中没删掉的缺陷
--bug=1049852 --user=王孝刚 【应用编排】应用日志清除后,对话中的文件在file表中没删掉 https://www.tapd.cn/57709429/s/1622739
1 parent 433ae5d commit 4cc84a6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

apps/common/job/clean_chat_job.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@ def clean_chat_log_job():
3939
with transaction.atomic():
4040
logs_to_delete = Chat.objects.filter(query_conditions).values_list('id', flat=True)[:batch_size]
4141
count = logs_to_delete.count()
42+
logs_to_delete_str = [str(uuid) for uuid in logs_to_delete]
4243
if count == 0:
4344
break
4445
deleted_count, _ = Chat.objects.filter(id__in=logs_to_delete).delete()
4546
# 删除对应的文件
46-
File.objects.filter(meta__chat_id__in=[str(uuid) for uuid in logs_to_delete]).delete()
47+
File.objects.filter(meta__chat_id__in=logs_to_delete_str).delete()
4748
if deleted_count < batch_size:
4849
break
4950

@@ -57,6 +58,6 @@ def run():
5758
existing_job = scheduler.get_job(job_id='clean_chat_log')
5859
if existing_job is not None:
5960
existing_job.remove()
60-
scheduler.add_job(clean_chat_log_job, 'cron', hour='0', minute='5', id='clean_chat_log')
61+
scheduler.add_job(clean_chat_log_job, 'cron', minute='*/5', id='clean_chat_log')
6162
finally:
6263
lock.un_lock('clean_chat_log_job')

0 commit comments

Comments
 (0)