feat(growth): same-day 1-day baselines for new videos
Let 1-day view growth use a zero baseline for videos published today, and the first successful sample for older videos ingested today, without mixing those into 7/30-day rankings.
This commit is contained in:
1 parent
8e7ead1669
commit
c5b7185675
21 files changed
+411
-59
No files matched your search
+11
-3
@@ -444,19 +444,22 @@ def test_run_recent_videos_refreshes_without_completion_markers():
|
||||
1: view_for(1, view=111),
|
||||
2: view_for(2, view=222),
|
||||
3: view_for(3, view=333),
|
||||
4: view_for(4, view=444),
|
||||
})
|
||||
db, repo, service = make_service(tmp, transport, track_fans=())
|
||||
try:
|
||||
# 1/2 在墙钟近 2 天内;3 为旧片
|
||||
# 1/2 在墙钟近 2 天内;3 为旧片;4 发布已久但当天入库,不进小时任务
|
||||
add_video(repo, 1)
|
||||
add_video(repo, 2)
|
||||
add_video(repo, 3)
|
||||
add_video(repo, 4)
|
||||
repo.db.write(lambda conn: conn.executemany(
|
||||
"UPDATE video SET pubdate = ? WHERE aid = ?",
|
||||
[
|
||||
(clock - 3600, 1),
|
||||
(clock - 86400, 2),
|
||||
(clock - 10 * 86400, 3),
|
||||
(clock - 10 * 86400, 4),
|
||||
],
|
||||
))
|
||||
# 预置同日 ok=1,验证小时任务可覆盖刷新
|
||||
@@ -477,23 +480,27 @@ def test_run_recent_videos_refreshes_without_completion_markers():
|
||||
)) == {1, 2}
|
||||
|
||||
row = repo.db.read(lambda conn: dict(conn.execute(
|
||||
"SELECT view, ok, captured_at FROM snapshot WHERE stat_date=? AND aid=1",
|
||||
"SELECT view, ok, captured_at, view_open FROM snapshot "
|
||||
"WHERE stat_date=? AND aid=1",
|
||||
(DATE,),
|
||||
).fetchone()))
|
||||
assert row["view"] == 111
|
||||
assert row["ok"] == 1
|
||||
assert row["captured_at"] == clock
|
||||
assert row["view_open"] == 1
|
||||
|
||||
# 完成日 / 备份标记保持原样
|
||||
assert repo.kv_get(service.completed_key(DATE)) is None
|
||||
assert repo.kv_get("snapshot:last_completed") is None
|
||||
assert repo.kv_get(service.backup_key(DATE)) is None
|
||||
assert transport.count("/web-interface/view") == 2
|
||||
assert repo.get_snapshot(DATE, 4) is None
|
||||
|
||||
# 全量任务随后才写完成日;且已 ok=1 的跳过
|
||||
full = service.run_videos(date=DATE)
|
||||
assert full.skipped >= 2 # 1、2 已被小时任务写过
|
||||
assert full.success >= 1 # 至少旧片 3
|
||||
assert full.success >= 1 # 至少旧片 3、4
|
||||
assert repo.get_snapshot(DATE, 4) is not None
|
||||
assert repo.kv_get(service.completed_key(DATE)) == "1"
|
||||
assert repo.kv_get("snapshot:last_completed") == DATE
|
||||
finally:
|
||||
@@ -562,6 +569,7 @@ def test_seed_from_last_completed_does_not_mark_completed():
|
||||
row = repo.get_snapshot(today, 1)
|
||||
assert row is not None
|
||||
assert int(row["view"]) == 10
|
||||
assert int(row["view_open"]) == 10
|
||||
assert row["src"] == "seed"
|
||||
fan = repo.get_up_stat(today, 37754047)
|
||||
assert fan is not None and int(fan["follower"]) == 100
|
||||
|
||||
Reference in new issue
Block a user