Files
koc-loop/mysql/0021_reconcile_claimed_quantity.sql
ABAPPLO 2db06063ee fix: 采集失败不降级有数据分行+任务领取计数对齐实际分发行数
- 采集失败时按 latest_likes 分流:无数据才标 failed,已有历史数据保持
  success 并注明沿用上次数据,collection_updated_at 不动;run 行照实记失败
- 种子 seedIfEmpty 末尾统一对账 claimed_quantity,杜绝演示数据口径漂移
- 新增 mysql/0021 对账迁移,修复 0020 物理合并遗留的生产计数漂移
- 运营端展示全面改读实时 dist_total(任务卡双面板/项目树/概览/进度),
  project-service 查询补 dist_total 子查询
- 走查实证:卡片 7/18 vs 详情已领取 2 两处口径打架;保存采集计划补采
  失败会把历史成功行改写为 failed
2026-10-08 14:30:36 +08:00

14 lines
610 B
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- 校准任务领取计数:0020 物理合并删除了伴生回收任务的分发/领取行、并搬运了
-- 部分回收到父任务分发行,但没有同步父任务 claimed_quantity,任务卡「已领取」
-- 会与实际分发行数漂移。领取(+1)/释放(-1) 路径共同维护的不变式是:
-- content_publish 任务的 claimed_quantity = 当前分发行数,此处按此对账。
UPDATE tasks
SET claimed_quantity = (
SELECT COUNT(*) FROM distributions d
WHERE d.task_id = tasks.id
)
WHERE claimed_quantity <> (
SELECT COUNT(*) FROM distributions d
WHERE d.task_id = tasks.id
);