feat: 原始上报数据存储(raw_batch 表/脱敏/访客关联/详情页 Tab/30天清理)

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
浅念
2026-09-16 15:42:06 +08:00
parent 1cadee16bd
commit 21ca43248a
10 changed files with 534 additions and 6 deletions
@@ -0,0 +1,19 @@
from datetime import timedelta
from django.core.management.base import BaseCommand
from django.utils import timezone
from tracker.models import RawBatch
class Command(BaseCommand):
# 生产调度:1Panel 计划任务每日执行(与 refresh_stats 同款)
# docker exec <web容器> python manage.py cleanup_raw --days 30
help = "清理 N 天前的原始上报批次(raw_batch 默认保留 30 天)"
def add_arguments(self, parser):
parser.add_argument("--days", type=int, default=30)
def handle(self, *args, **opts):
cutoff = timezone.now() - timedelta(days=opts["days"])
deleted, _ = RawBatch.objects.filter(received_at__lt=cutoff).delete()
self.stdout.write(f"deleted {deleted} raw batches")