fix(tools): backfill fan counts in chronological order

This commit is contained in:
kairee committed 2026-10-31 23:10:54 +08:00
1 parent 94ee9aefd1
commit e7cae035e0
2 files changed
+14 -3

No files matched your search

+7 -3
View File
@@ -327,10 +327,14 @@ def _seed_up_stats(
follower = int(data.get("follower") or 0)
following = data.get("following")
current = follower
for offset in range(days, 0, -1):
stat_date = (latest_day - timedelta(days=offset)).isoformat()
# values[0] 对应 latest-1,values[-1] 对应 latest-days。
values: list[int] = []
for _ in range(days):
decrement = max(1, int(round(current * rng.uniform(0.00015, 0.0006))))
current = max(0, current - decrement)
values.append(current)
for offset in range(days, 0, -1):
stat_date = (latest_day - timedelta(days=offset)).isoformat()
conn.execute(
"""
INSERT OR REPLACE INTO up_stat(
@@ -340,7 +344,7 @@ def _seed_up_stats(
(
stat_date,
int(mid),
current,
values[offset - 1],
following,
int(_day_start(latest_day - timedelta(days=offset)) + 60),
),