诚实性修复: API限流Retry-After(wait=60s)+断言 / purge定时接线(04:00 cron+actor+测试) / Channel表单校验(ref+rules+validate) / README PG数字513

This commit is contained in:
seagull
2026-09-12 02:20:50 +08:00
parent b3f3095d53
commit 67540e8d30
40 changed files with 1805 additions and 31 deletions
+26
View File
@@ -0,0 +1,26 @@
"""审计日志保留定时任务(P1-3 · Dramatiq actor,cron 每日调用)。
复用 `purge_audit_logs` management command(默认保留 180 天、分批删、
`--yes` 防手滑),与 `apps/billing/tasks.py` / `apps/notify/tasks.py`
同一范式:业务函数可直接单测,actor 只做薄包装。
"""
def purge_expired_audit_logs(days: int = 180) -> str:
"""删除早于保留窗口的审计日志,返回 command 回执。"""
from django.core.management import call_command
return call_command("purge_audit_logs", days=days, yes=True)
try:
import dramatiq
purge_expired_audit_logs_actor = dramatiq.actor(
purge_expired_audit_logs,
actor_name="purge_expired_audit_logs",
max_retries=1,
time_limit=600_000,
)
except ImportError: # pragma: no cover —— 未装 dramatiq 的精简环境
purge_expired_audit_logs_actor = None