feat: 品牌抓取历史(brand_crawl_logs)+ 品牌页展示

crawl_tasks 每品牌只有一行(uq_crawl_tasks_brand),入队/完成都是覆盖,
答不了「什么时候爬过、爬了几次、哪次没抓到」。故新增 append-only 历史表:

- 在 Report 的同一事务里写一条:品牌 / 任务 / 状态 / 第几次尝试 /
  场次上限 / 实际上报场次 / 错误 / 执行者 / 领取与回报时间
- 写入后只保留该品牌最近 30 条(CrawlLogKeepPerBrand),
  历史用于排障而非归档,避免无限增长
- 品牌详情页新增「抓取历史」区块(结果 / 明细 / 耗时 / 执行者),
  与「更新记录」上下相邻,构成「抓取一次 → 每场入库结果」的完整链路

量级:每品牌每次抓取 1 行、约 200B(含索引);全站跑一遍 23237 行 ≈ 4.6MB。
This commit is contained in:
toom1996
2026-10-25 11:37:43 +08:00
parent c8a70760cc
commit 64b264ee73
6 changed files with 172 additions and 3 deletions

View File

@ -13,6 +13,25 @@
</form>
{{if .UID}}
<h2 style="margin-top:32px">抓取历史</h2>
<p class="muted">每次抓取一条(每品牌保留最近 30 条)。这一层回答「什么时候爬的、爬了几场、哪次没抓到」。</p>
{{if .CrawlLogs}}
<table>
<thead><tr><th>时间</th><th>结果</th><th>明细</th><th>耗时</th><th>执行者</th></tr></thead>
<tbody>
{{range .CrawlLogs}}<tr>
<td>{{.TimeText}}</td>
<td>{{.StatusText}}</td>
<td>{{.Detail}}</td>
<td>{{if .Elapsed}}{{.Elapsed}}{{else}}-{{end}}</td>
<td><code>{{if .Worker}}{{.Worker}}{{else}}-{{end}}</code></td>
</tr>{{end}}
</tbody>
</table>
{{else}}
<p class="muted">还没有抓取记录。把品牌加入抓取队列后,每次抓取(抓到几场 / 失败原因 / 谁跑的)都会出现在这里。</p>
{{end}}
<h2 style="margin-top:32px">更新记录</h2>
<p class="muted">
{{if .LastCrawl}}最近抓取:{{.LastCrawl}} · {{.CrawlStatus}}{{else}}还没有抓取记录{{end}}