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">
|
||||
|
||||
Reference in new issue
Block a user