crawl_tasks 每品牌只有一行(uq_crawl_tasks_brand),入队/完成都是覆盖, 答不了「什么时候爬过、爬了几次、哪次没抓到」。故新增 append-only 历史表: - 在 Report 的同一事务里写一条:品牌 / 任务 / 状态 / 第几次尝试 / 场次上限 / 实际上报场次 / 错误 / 执行者 / 领取与回报时间 - 写入后只保留该品牌最近 30 条(CrawlLogKeepPerBrand), 历史用于排障而非归档,避免无限增长 - 品牌详情页新增「抓取历史」区块(结果 / 明细 / 耗时 / 执行者), 与「更新记录」上下相邻,构成「抓取一次 → 每场入库结果」的完整链路 量级:每品牌每次抓取 1 行、约 200B(含索引);全站跑一遍 23237 行 ≈ 4.6MB。
58 lines
2.4 KiB
HTML
58 lines
2.4 KiB
HTML
{{define "title"}}{{if .UID}}编辑品牌{{else}}新建品牌{{end}} · 管理后台{{end}}
|
||
{{define "barLabel"}}管理后台 · {{if .UID}}编辑品牌{{else}}新建品牌{{end}}{{end}}
|
||
{{define "barRight"}}<a href="/admin/brands">返回列表</a> · <a href="/admin/logout">退出</a>{{end}}
|
||
{{define "content"}}
|
||
{{template "bar" .}}
|
||
<div class="main">
|
||
<h1>{{if .UID}}编辑品牌{{else}}新建品牌{{end}}</h1>
|
||
<form method="post" action="{{if .UID}}/admin/brands/{{.UID}}{{else}}/admin/brands{{end}}">
|
||
{{if .Error}}<div class="err">{{.Error}}</div>{{end}}
|
||
<label>英文名(name_en)</label><input name="name_en" value="{{.NameEn}}" placeholder="如 Acne Studios">
|
||
<label>中文名(name_cn)</label><input name="name_cn" value="{{.NameCn}}" placeholder="如 艾克妮">
|
||
<button type="submit">{{if .UID}}保存{{else}}创建{{end}}</button>
|
||
</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}}
|
||
(只显示最近 30 条入库记录;抓取侧每品牌只保留最近一次的状态)
|
||
</p>
|
||
{{if .Records}}
|
||
<table>
|
||
<thead><tr><th>时间</th><th>场次</th><th>结果</th><th>明细</th></tr></thead>
|
||
<tbody>
|
||
{{range .Records}}<tr>
|
||
<td>{{.TimeText}}</td>
|
||
<td>{{if .Title}}{{.Title}}{{else}}-{{end}}</td>
|
||
<td>{{.OutcomeText}}</td>
|
||
<td>{{.Detail}}</td>
|
||
</tr>{{end}}
|
||
</tbody>
|
||
</table>
|
||
{{else}}
|
||
<p class="muted">还没有入库记录。把品牌加入抓取队列后,每一场的处理结果(新建 / 已存在跳过 / 失败原因)都会出现在这里。</p>
|
||
{{end}}
|
||
{{end}}
|
||
</div>
|
||
{{end}}
|