Skip to content

Commit

Permalink
fix(mail_clean_document_notify_task): use defaultdict for dataset log…
Browse files Browse the repository at this point in the history
…s mapping and add check for current owner join

Signed-off-by: -LAN- <[email protected]>
  • Loading branch information
laipz8200 committed Dec 25, 2024
1 parent 3df260b commit db4bbd9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion api/schedule/mail_clean_document_notify_task.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
import time
from collections import defaultdict

import click
from celery import shared_task # type: ignore
Expand All @@ -26,7 +27,7 @@ def send_document_clean_notify_task():
try:
dataset_auto_disable_logs = DatasetAutoDisableLog.query.filter(DatasetAutoDisableLog.notified == False).all()
# group by tenant_id
dataset_auto_disable_logs_map = {}
dataset_auto_disable_logs_map: dict[str, list[DatasetAutoDisableLog]] = defaultdict(list)
for dataset_auto_disable_log in dataset_auto_disable_logs:
dataset_auto_disable_logs_map[dataset_auto_disable_log.tenant_id].append(dataset_auto_disable_log)

Expand All @@ -36,6 +37,8 @@ def send_document_clean_notify_task():
if not tenant:
continue
current_owner_join = TenantAccountJoin.query.filter_by(tenant_id=tenant.id, role="owner").first()
if not current_owner_join:
continue
account = Account.query.filter(Account.id == current_owner_join.account_id).first()
if not account:
continue
Expand Down

0 comments on commit db4bbd9

Please sign in to comment.