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:
bot-ci committed 2026-11-02 10:00:02 +08:00
1 parent 04716aec1b
commit 9163f47b76
15 files changed
+496 -22

No files matched your search

+24
View File
@@ -49,6 +49,7 @@ DEFAULT_ANALYTICS: dict[str, Any] = {
"min_view_for_ranking": 2000,
"video_shrink_minutes": 60,
"shrink_minutes": None,
"home_growth_days": "auto",
}
DEFAULT_CONFIG: dict[str, Any] = {
@@ -84,6 +85,8 @@ DEFAULT_CONFIG: dict[str, Any] = {
"discover_minutes": 60,
"snapshot_at": "00:01",
"candidate_ttl_days": 7,
"recent_snapshot_minutes": 60,
"recent_video_days": 2,
},
"discover": {
"keywords": ["咻咻满"],
@@ -177,6 +180,8 @@ class ScheduleConfig:
discover_minutes: int
snapshot_at: str
candidate_ttl_days: int
recent_snapshot_minutes: int
recent_video_days: int
@dataclass(frozen=True)
@@ -200,6 +205,7 @@ class AnalyticsConfig:
min_view_for_ranking: int
video_shrink_minutes: int
shrink_minutes: int | None
home_growth_days: str | int
@dataclass(frozen=True)
@@ -456,6 +462,16 @@ def _build_config(data: Mapping[str, Any], path: Path) -> AppConfig:
"schedule.candidate_ttl_days",
minimum=1,
),
recent_snapshot_minutes=_as_int(
sched_raw.get("recent_snapshot_minutes", 60),
"schedule.recent_snapshot_minutes",
minimum=1,
),
recent_video_days=_as_int(
sched_raw.get("recent_video_days", 2),
"schedule.recent_video_days",
minimum=1,
),
)
notify_raw = data["notify"]
@@ -533,6 +549,13 @@ def _build_config(data: Mapping[str, Any], path: Path) -> AppConfig:
if not isinstance(analytics_raw, Mapping):
raise ConfigError("analytics 必须是对象")
shrink_raw = analytics_raw.get("shrink_minutes")
home_growth_raw = analytics_raw.get("home_growth_days", "auto")
if home_growth_raw == "auto":
home_growth_days: str | int = "auto"
elif home_growth_raw in (1, 7):
home_growth_days = int(home_growth_raw)
else:
raise ConfigError('analytics.home_growth_days 必须是 "auto"、1 或 7')
analytics = AnalyticsConfig(
min_duration_seconds=_as_int(
analytics_raw.get("min_duration_seconds", 600),
@@ -559,6 +582,7 @@ def _build_config(data: Mapping[str, Any], path: Path) -> AppConfig:
shrink_raw, "analytics.shrink_minutes", minimum=1
)
),
home_growth_days=home_growth_days,
)
return AppConfig(