feat(web): show cumulative fan range and limit recent records

This commit is contained in:
kairee committed 2026-11-01 02:14:10 +08:00
1 parent b6a9f598b5
commit d8e9a7b0f0
5 files changed
+48 -9

No files matched your search

+13
View File
@@ -213,6 +213,19 @@ def test_fans_candidates_system_and_export():
wide = q.fans(days=30)
assert wide["dates"] == list(DATES)
# “最近记录”只返回最近 14 天,早于窗口的记录不进入表格
db.write(lambda conn: conn.execute(
"INSERT OR REPLACE INTO up_stat"
"(stat_date, mid, follower, following, captured_at, ok) "
"VALUES (?, ?, ?, NULL, 1, 1)",
("2026-10-01", 37754047, 900),
))
recent = q.fans(days=90)
assert recent["recent_days"] == 14
assert [point["stat_date"] for point in recent["recent_points"]] == list(DATES)
one_day = q.fans(days=90, recent_days=1)
assert [point["stat_date"] for point in one_day["recent_points"]] == [DATES[-1]]
# 缺失前一天时不能把跨多天的变化标成“日增”
db.write(lambda conn: conn.execute(
"DELETE FROM up_stat WHERE mid=37754047 AND stat_date=?",
+9
View File
@@ -102,6 +102,15 @@ def test_readonly_routes_and_static():
assert status == 200
assert json.loads(payload)["data"]["sort"] == "avg_views"
status, _, payload = running.request("/api/fans?days=7&recent_days=14")
assert status == 200
fans = json.loads(payload)["data"]
assert fans["recent_days"] == 14
assert all(
point["stat_date"] >= "2026-10-18"
for point in fans["recent_points"]
)
status, headers, payload = running.request("/api/videos", method="HEAD")
assert status == 200 and payload == b""
assert "Content-Length" in headers