Files
OnlineJudge/problem/serializers.py
yuetsh 085110544d chore: 再清 6 处零引用的函数/类(-47 行)
utils/tasks.py            整个文件(delete_files)
  utils/async_helpers.py    async_cache_delete
  problem/utils.py          build_problem_template
  utils/shortcuts.py        build_query_string
  achievement/checker.py    get_or_create_stat
  problem/serializers.py    TemplateSerializer

delete_files 的唯一调用者是上一个 commit 删掉的 DownloadContestSubmissions
(`delete_files.send_with_options(args=(zip_path,), delay=300_000)`,生成 zip 后
延时清理)。django_dramatiq 按约定自动发现各 app 的 tasks.py,缺一个文件不报错,
已实跑确认 judge / achievement / flowchart 三处的 actor 都还在。

## 扫出来但**不能删**的,记在这里免得下次又查一遍

**achievement/metrics.py 的 18 个指标类**:静态扫描报"零引用",因为类名确实
从不被引用 —— 它们靠 `@metric(key, name)` 装饰器在**定义时**注册进
METRIC_REGISTRY。删掉会静默丢掉成就维度,而且不报错。运行时确认注册表里
18 个一个不少。

**async_cache_get / async_cache_set**:各 6 处引用,只有 delete 那个是死的。
**parse_problem_template**:5 处引用,和被删的 build_problem_template 只是名字像。

**User 模型上的 open_api / open_api_appkey / two_factor_auth / session_keys**:
删字段要迁移,会改生产库结构 —— 而新后端正是靠"库结构与旧后端逐列一致"才能
回滚(阶段 5 演练验证过)。切换完成之前不动。

## 验证

manage.py check 通过;起本地 Django + PostgreSQL 实跑 14 个端点全部 200
(前台 10 个 + 后台 4 个);ruff 全绿;行尾未被改动。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-08 07:23:42 -06:00

8.4 KiB