fix(growth): require a 1000-view baseline on the rate board
Keep small-base videos on the delta board only, and raise the smoothing prior to 1000 so videos that just clear the floor do not dominate the ranking.
This commit is contained in:
1 parent
39a6537f67
commit
00572a3429
11 files changed
+47
-27
No files matched your search
@@ -59,6 +59,19 @@ def _chunks(values: Sequence[int], size: int = 400) -> Iterable[Sequence[int]]:
|
||||
yield values[index:index + size]
|
||||
|
||||
|
||||
def _growth_baseline_view(item: Mapping[str, Any]) -> int | None:
|
||||
"""增速分母:当前播放减去区间增量。zero 基线的增量等于当前播放,结果为 0。"""
|
||||
growth = item.get("growth") or {}
|
||||
current = (item.get("metrics") or {}).get("view")
|
||||
delta = growth.get("delta")
|
||||
if current is None or delta is None:
|
||||
return None
|
||||
try:
|
||||
return int(current) - int(delta)
|
||||
except (TypeError, ValueError):
|
||||
return None
|
||||
|
||||
|
||||
def _date_minus(day: str, days: int) -> str:
|
||||
return (date.fromisoformat(day) - timedelta(days=int(days))).isoformat()
|
||||
|
||||
@@ -1036,7 +1049,7 @@ class DashboardQueries:
|
||||
item for item in items
|
||||
if item.get("growth", {}).get("baseline") != "zero"
|
||||
and item.get("growth", {}).get("rate") is not None
|
||||
and (item["metrics"] or {}).get("view", 0) >= MIN_VIEW_FOR_GROWTH_RATE
|
||||
and (_growth_baseline_view(item) or 0) >= MIN_VIEW_FOR_GROWTH_RATE
|
||||
]
|
||||
|
||||
rate_prior = max(0, int(analytics.growth_rate_prior))
|
||||
@@ -1087,8 +1100,8 @@ class DashboardQueries:
|
||||
available = False
|
||||
if growth_days == 1 and sort == "growth_rate":
|
||||
reason = (
|
||||
"近 1 日增速需要前一日快照,或更早发布的新入库当天至少两次成功采样;"
|
||||
"当日发布不计入增速"
|
||||
"近 1 日增速需要基线播放至少 "
|
||||
f"{MIN_VIEW_FOR_GROWTH_RATE};当日发布不计入增速"
|
||||
)
|
||||
elif growth_days == 1:
|
||||
reason = (
|
||||
|
||||
Reference in new issue
Block a user