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
@@ -139,6 +139,9 @@ def test_analytics_defaults_and_validation():
|
||||
assert cfg.analytics.min_view_for_ranking == 2000
|
||||
assert cfg.analytics.video_shrink_minutes == 60
|
||||
assert cfg.analytics.shrink_minutes is None
|
||||
assert cfg.analytics.home_growth_days == "auto"
|
||||
assert cfg.schedule.recent_snapshot_minutes == 60
|
||||
assert cfg.schedule.recent_video_days == 2
|
||||
|
||||
data = base_config()
|
||||
data["analytics"] = {
|
||||
@@ -147,6 +150,14 @@ def test_analytics_defaults_and_validation():
|
||||
"min_view_for_ranking": 100,
|
||||
"video_shrink_minutes": 30,
|
||||
"shrink_minutes": 90,
|
||||
"home_growth_days": 1,
|
||||
}
|
||||
data["schedule"] = {
|
||||
"discover_minutes": 30,
|
||||
"snapshot_at": "00:01",
|
||||
"candidate_ttl_days": 7,
|
||||
"recent_snapshot_minutes": 15,
|
||||
"recent_video_days": 3,
|
||||
}
|
||||
write(path, data)
|
||||
cfg = load_config(path, env={})
|
||||
@@ -155,6 +166,14 @@ def test_analytics_defaults_and_validation():
|
||||
assert cfg.analytics.min_view_for_ranking == 100
|
||||
assert cfg.analytics.video_shrink_minutes == 30
|
||||
assert cfg.analytics.shrink_minutes == 90
|
||||
assert cfg.analytics.home_growth_days == 1
|
||||
assert cfg.schedule.recent_snapshot_minutes == 15
|
||||
assert cfg.schedule.recent_video_days == 3
|
||||
|
||||
data = base_config()
|
||||
data["analytics"] = {"home_growth_days": 7}
|
||||
write(path, data)
|
||||
assert load_config(path, env={}).analytics.home_growth_days == 7
|
||||
|
||||
for bad, hint in (
|
||||
({"min_duration_seconds": -1}, "min_duration_seconds"),
|
||||
@@ -163,6 +182,9 @@ def test_analytics_defaults_and_validation():
|
||||
({"video_shrink_minutes": -1}, "video_shrink_minutes"),
|
||||
({"shrink_minutes": 0}, "shrink_minutes"),
|
||||
({"shrink_minutes": "auto"}, "shrink_minutes"),
|
||||
({"home_growth_days": 3}, "home_growth_days"),
|
||||
({"home_growth_days": "7"}, "home_growth_days"),
|
||||
({"home_growth_days": 0}, "home_growth_days"),
|
||||
):
|
||||
data = base_config()
|
||||
data["analytics"] = bad
|
||||
@@ -243,12 +265,38 @@ def test_web_track_defaults_and_validation():
|
||||
raise AssertionError("web.track 必须是对象")
|
||||
|
||||
|
||||
def test_schedule_recent_validation():
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
path = Path(tmp) / "config.json"
|
||||
for bad, hint in (
|
||||
({"recent_snapshot_minutes": 0}, "recent_snapshot_minutes"),
|
||||
({"recent_video_days": 0}, "recent_video_days"),
|
||||
({"recent_snapshot_minutes": -5}, "recent_snapshot_minutes"),
|
||||
):
|
||||
data = base_config()
|
||||
data["schedule"] = {
|
||||
"discover_minutes": 60,
|
||||
"snapshot_at": "00:01",
|
||||
"candidate_ttl_days": 7,
|
||||
**bad,
|
||||
}
|
||||
write(path, data)
|
||||
try:
|
||||
load_config(path, env={})
|
||||
except ConfigError as exc:
|
||||
assert hint in str(exc), (bad, str(exc))
|
||||
else:
|
||||
raise AssertionError(f"非法 schedule 必须拒绝: {bad}")
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
test_dual_accounts_and_env_override()
|
||||
test_flat_and_missing_account_rejected()
|
||||
test_validation_require_read_auth_and_hot_reload()
|
||||
test_invalid_values()
|
||||
test_analytics_defaults_and_validation()
|
||||
test_schedule_recent_validation()
|
||||
test_web_track_defaults_and_validation()
|
||||
print("OK: 双账号配置加载、拒绝 flat 格式、ENV 覆盖、热加载与 analytics/web.track 测试全部通过")
|
||||
|
||||
|
||||
Reference in new issue
Block a user