feat: 入库结果落库 + 品牌详情展示更新记录

背景:任务只有 status=done,分不清「新建」「已存在跳过」「已删除跳过」,
品牌更新历史只能在进程日志里翻,日志一滚就没了。

- ingest_jobs 新增 outcome / note / brand_id(迁移 2026-10-25-01)
  outcome 记结果类型,note 记人话细节(新建 N 张图 / 已存在(status=published))
- 提交任务时解出 brand_id 落库,品牌详情页按 (brand_id, id DESC) 直接查
- 处理时优先用 job.brand_id,payload 里的 hashid 只作老任务兜底:
  避免「别的实例盐不同 → 解出错品牌 → 整场 brand not found」再发生
- 品牌编辑页新增「更新记录」区块:时间 / 场次 / 结果 / 明细(含失败原因与尝试次数)
- 测试:fake 仓储补齐新接口,capture 仓储记录 outcome 供断言
This commit is contained in:
toom1996
2026-10-25 11:06:16 +08:00
parent c483018cc8
commit c8a70760cc
9 changed files with 297 additions and 24 deletions

View File

@ -19,7 +19,9 @@ type captureIngestRepo struct {
repository.IngestRepository
createdRW *model.BrandRunway
createdImages []model.BrandRunwayImage
deletedEntity bool // 模拟实体键已软删(删除即永久:应跳过重爬,不重新写入)
deletedEntity bool // 模拟实体键已软删(删除即永久:应跳过重爬,不重新写入)
doneOutcome string // 最近一次 MarkDone 的结果类型(断言「跳过」是否标清楚)
doneNote string
}
func (c *captureIngestRepo) RunwayEntityState(ctx context.Context, brandID uint32, seasonCode, collectionType string) (uint32, string, bool, bool, error) {
@ -35,7 +37,17 @@ func (c *captureIngestRepo) CreateRunwayWithImages(ctx context.Context, rw *mode
return 1, nil
}
func (c *captureIngestRepo) MarkDone(ctx context.Context, id uint32) error { return nil }
func (c *captureIngestRepo) MarkDone(ctx context.Context, id uint32, outcome, note string) error {
// 记下 outcome/note,供「跳过的场次也要标清楚原因」这类断言使用
c.doneOutcome = outcome
c.doneNote = note
return nil
}
// ListByBrand 捕获型仓储不需要品牌维度查询。
func (c *captureIngestRepo) ListByBrand(ctx context.Context, brandID uint32, limit int) ([]repository.BrandIngestRecord, error) {
return nil, nil
}
// RepairRunwayDetailParents 在捕获型仓储里无需真正落库回填,直接返回成功(被测路径只关心落库记录)。
func (c *captureIngestRepo) RepairRunwayDetailParents(ctx context.Context, runwayID uint32) error {