feat: home growth auto(7→1) and hourly recent-video snapshot
- Add analytics.home_growth_days (auto|1|7); API growth_days=auto tries 7 then 1 - Homepage shows active window and growth-board link; clearer empty reason - New snapshot_recent scheduler task (schedule.recent_snapshot_minutes/days) - run_recent_videos refreshes new aids only; never touches completed/backup - Full 00:01 job keeps ok=1 skip (covers hourly refresh within 1h); mutex with recent
This commit is contained in:
1 parent
04716aec1b
commit
9163f47b76
15 files changed
+496
-22
No files matched your search
@@ -47,7 +47,8 @@ export async function renderHome(root) {
|
||||
api("/api/overview"),
|
||||
api("/api/videos", { sort: "published", within_days: 14, limit: 6 }),
|
||||
api("/api/videos", { sort: "heat", limit: 6 }),
|
||||
api("/api/videos", { sort: "growth", growth_days: 7, limit: 6 }),
|
||||
// auto:服务端按 analytics.home_growth_days 解析;默认先试 7 天再降到 1 天
|
||||
api("/api/videos", { sort: "growth", growth_days: "auto", limit: 6 }),
|
||||
]);
|
||||
|
||||
const fans = overview.fans;
|
||||
@@ -59,6 +60,13 @@ export async function renderHome(root) {
|
||||
const pending = overview.counts?.candidates_pending || 0;
|
||||
// 候选提示仅对已登录(或未启用鉴权)用户可见,访客不展示运行期信息。
|
||||
const showCandidates = pending > 0 && canAccessProtected();
|
||||
const growthDays = Number(growth.growth_days) || 1;
|
||||
const growthLabel = `近 ${growthDays} 日`;
|
||||
const growthEmptyTitle = growth.reason
|
||||
|| `近 ${growthDays} 日增长暂不可用`;
|
||||
const growthEmptyHint = growthDays <= 1
|
||||
? "当前快照不足,完成至少 2 天快照后即可显示播放增量。"
|
||||
: `需要至少 ${growthDays + 1} 天快照才能计算近 ${growthDays} 日增长。`;
|
||||
|
||||
root.innerHTML = `<section class="page home-page">
|
||||
<header class="page-head home-head">
|
||||
@@ -101,12 +109,12 @@ export async function renderHome(root) {
|
||||
|
||||
<section class="panel">
|
||||
<div class="section-head">
|
||||
<h2>增长动态</h2>
|
||||
<a class="text-link" href="/videos?sort=growth&growth_days=7">增长榜</a>
|
||||
<h2>增长动态 · ${escapeHtml(growthLabel)}</h2>
|
||||
<a class="text-link" href="/videos?sort=growth&growth_days=${growthDays}">增长榜</a>
|
||||
</div>
|
||||
${growth.available && growth.items.length
|
||||
? `<div class="media-grid">${growth.items.map((item, index) => growthCard(item, index)).join("")}</div>`
|
||||
: emptyState("需要至少 2 天快照", growth.reason || "当前只有 1 个数据点,明天开始显示播放增量。")}
|
||||
: emptyState(growthEmptyTitle, growthEmptyHint)}
|
||||
</section>
|
||||
|
||||
<section class="panel">
|
||||
|
||||
@@ -38,6 +38,7 @@ export async function renderSystem(root) {
|
||||
const health = system.snapshot_health || { total: 0, ok: 0, failed: 0 };
|
||||
const counts = system.counts || {};
|
||||
const next = system.next_runs || {};
|
||||
const running = system.running || {};
|
||||
|
||||
const visitExtra = visitStats
|
||||
? `<span class="section-note">近 ${visitStats.days} 天 · ${visitStats.pending ? "含未落库缓冲" : "已落库"}</span>`
|
||||
@@ -92,12 +93,13 @@ export async function renderSystem(root) {
|
||||
|
||||
<section class="panel">
|
||||
${sectionHeader("预计下次运行")}
|
||||
<div class="status-grid status-row-3">
|
||||
<div class="status-grid status-row-4">
|
||||
<div><span>咻咻满粉丝数更新</span><strong>${running.fans ? "运行中" : escapeHtml(formatDateTime(next.fans))}</strong></div>
|
||||
<div><span>视频数据快照 + UP 信息</span><strong>${running.snapshot ? "运行中" : escapeHtml(formatDateTime(next.snapshot))}</strong></div>
|
||||
<div><span>新视频小时同步</span><strong>${running.snapshot_recent ? "运行中" : escapeHtml(formatDateTime(next.snapshot_recent))}</strong></div>
|
||||
<div><span>新视频搜索</span><strong>${running.discover || running.discovery ? "运行中" : escapeHtml(formatDateTime(next.discover))}</strong></div>
|
||||
</div>
|
||||
<p class="section-note">进行中显示「运行中」;空闲时按该任务上次完成时间推算下次运行,不按墙钟抢跑。</p>
|
||||
<p class="section-note">进行中显示「运行中」;空闲时按该任务上次完成时间推算下次运行,不按墙钟抢跑。新视频小时同步与全站快照互斥。</p>
|
||||
</section>
|
||||
|
||||
<section class="panel">
|
||||
|
||||
Reference in new issue
Block a user