fix(web): fix UP card layout and fan delta semantics

This commit is contained in:
kairee committed 2026-11-01 00:06:43 +08:00
1 parent 7fcd1db987
commit f9a5478800
7 files changed
+51 -16

No files matched your search

+25 -5
View File
@@ -474,11 +474,21 @@ class DashboardQueries:
return None
current = ok_rows[-1]
previous = ok_rows[-2] if len(ok_rows) >= 2 else None
if previous is not None:
try:
gap = (
date.fromisoformat(str(current["stat_date"]))
- date.fromisoformat(str(previous["stat_date"]))
).days
except ValueError:
gap = 0
if gap != 1:
previous = None
baseline = None
if latest:
cutoff = _date_minus(latest, 7)
candidates = [row for row in ok_rows if str(row["stat_date"]) <= cutoff]
baseline = candidates[-1] if candidates else None
by_date = {str(row["stat_date"]): row for row in ok_rows}
baseline = by_date.get(cutoff)
first = ok_rows[0]
return {
"mid": mid,
@@ -716,7 +726,7 @@ class DashboardQueries:
def list_ups(
self,
*,
sort: str = "views",
sort: str = "avg_views",
within_days: int | None = None,
q: str | None = None,
min_videos: int = 1,
@@ -944,9 +954,19 @@ class DashboardQueries:
ok_rows = [row for row in rows if int(row["ok"]) == 1]
current = ok_rows[-1] if ok_rows else rows[-1]
previous = ok_rows[-2] if len(ok_rows) >= 2 else None
if previous is not None:
try:
gap = (
date.fromisoformat(str(current["stat_date"]))
- date.fromisoformat(str(previous["stat_date"]))
).days
except ValueError:
gap = 0
if gap != 1:
previous = None
cutoff = _date_minus(latest, 7)
baselines = [row for row in ok_rows if str(row["stat_date"]) <= cutoff]
baseline = baselines[-1] if baselines else None
by_date = {str(row["stat_date"]): row for row in ok_rows}
baseline = by_date.get(cutoff)
first = ok_rows[0] if ok_rows else rows[0]
return {
"mid": selected,