feat: 跳过判定改为覆盖率(缺图能补,抓全才跳过)

此前只要某场秀已入库 >=10 张就整场跳过,当初只成功抓了十几张的场次
剩下的图永远补不上。

- payload 增加 expected_images(本场应有张数,后端据此算覆盖率)
- 跳过条件:images >= expected - 5;expected 未知时回落 10 张阈值
- 留 5 张余量:个别图在 Vogue 侧永久 404,要求一张不差会让这场秀
  永远判不完整、每次全量抓都重下一遍
This commit is contained in:
toom1996
2026-10-25 23:43:12 +08:00
parent 1ead57dd22
commit 463a57c497
4 changed files with 69 additions and 11 deletions

View File

@ -200,11 +200,11 @@ func ShowCoverageKey(year int, season, collectionType string) string {
return strconv.Itoa(year) + "|" + season + "|" + collectionType
}
// CoveredShows 取某品牌已入库的秀,返回「预检键 → 已有图片张数」。
// CoveredShows 取某品牌已入库的秀,返回「预检键 → 覆盖情况」。
//
// 用途:抓取前整场跳过已入库的秀。图片 key 是内容 sha1,不下载就无法知道
// 用途:抓取前整场跳过已经抓全的秀。图片 key 是内容 sha1,不下载就无法知道
// 一张图是否已经存在,所以「跳过」只能在场这一级做。
func (c *Client) CoveredShows(ctx context.Context, brandUID string) (map[string]int, error) {
func (c *Client) CoveredShows(ctx context.Context, brandUID string) (map[string]ShowCoverage, error) {
if c == nil || c.Endpoint == "" {
return nil, fmt.Errorf("ingest client 未配置")
}
@ -237,9 +237,9 @@ func (c *Client) CoveredShows(ctx context.Context, brandUID string) (map[string]
if err := json.Unmarshal(raw, &out); err != nil {
return nil, fmt.Errorf("shows/covered 解析失败: %w", err)
}
covered := make(map[string]int, len(out.Items))
covered := make(map[string]ShowCoverage, len(out.Items))
for _, it := range out.Items {
covered[ShowCoverageKey(int(it.Year), it.Season, it.CollectionType)] = it.Images
covered[ShowCoverageKey(int(it.Year), it.Season, it.CollectionType)] = it
}
return covered, nil
}
@ -287,7 +287,10 @@ type ShowCoverage struct {
Year uint16 `json:"year"`
Season string `json:"season"`
CollectionType string `json:"collection_type"`
Images int `json:"images"`
// Images 库里实际图片张数。
Images int `json:"images"`
// Expected 应有张数(spider 上次上报)。0 表示历史数据没有记录,判定时退化为阈值。
Expected int `json:"expected"`
}
func (c *Client) FetchPendingEmbeddings(ctx context.Context, kind string, limit int) ([]PendingEmbedding, int, error) {

View File

@ -25,6 +25,9 @@ type RunwayIngest struct {
CollectionType string `json:"collection_type"` // rtw / menswear / couture / resort / pre_fall
City string `json:"city"` // 地区/城市(street 用)
PublishedAt uint32 `json:"published_at"` // Vogue 详情页 datePublished 的 Unix 时间戳(秒);0=未抽取。标题缺年份时用于矫正 year
// ExpectedImages 本场秀应有的图片总数(含细节图)。
// 后端用它做覆盖率判定:实际入库张数接近它才算抓全;否则下次重爬会来补。
ExpectedImages int `json:"expected_images,omitempty"`
Images []string `json:"images"` // 兼容旧 worker:铺平的主图 URL 列表
// Looks 结构化「主图 + 细节图」分组(Vogue 一个 gallery item = 1 主图 + N 细节图)。
// 结构化上报时优先用 Looks;为空时 worker 回退到 Images(全部视为主图)。