fix(growth): rank the rate board by a smoothed score
Show the real percentage on the card, but sort with delta / (baseline + prior) so a small baseline cannot dominate. Same-day publishes stay off the rate board.
This commit is contained in:
1 parent
0f2ac612f5
commit
39a6537f67
14 files changed
+158
-16
No files matched your search
@@ -340,6 +340,29 @@ def compute_growth(
|
||||
)
|
||||
|
||||
|
||||
def smoothed_growth_rate(
|
||||
delta: int | float | None,
|
||||
previous: int | float | None,
|
||||
prior: int | float,
|
||||
) -> float | None:
|
||||
"""增速榜排序分:``Δ / (基线 + prior)``。
|
||||
|
||||
``rate`` 仍是真实相对增速。``prior`` 只削弱小基数在排序里的优势。
|
||||
"""
|
||||
if delta is None or previous is None or isinstance(delta, bool) or isinstance(previous, bool):
|
||||
return None
|
||||
if isinstance(prior, bool):
|
||||
return None
|
||||
try:
|
||||
strength = float(prior)
|
||||
base = max(0, int(previous)) + strength
|
||||
except (TypeError, ValueError):
|
||||
return None
|
||||
if strength < 0 or base <= 0:
|
||||
return None
|
||||
return int(delta) / base
|
||||
|
||||
|
||||
def normalize_cover(url: object) -> str | None:
|
||||
"""把 B 站封面统一为 https;空值返回 None。"""
|
||||
if not isinstance(url, str):
|
||||
|
||||
Reference in new issue
Block a user