feat(web): up avatars, follower count, and dedupe views/avg secondary

This commit is contained in:
kairee committed 2026-11-01 14:34:23 +08:00
1 parent 1ed3746f4b
commit 2ff3e7952b
23 files changed
+209 -58

No files matched your search

+23
View File
@@ -387,6 +387,7 @@ class DashboardQueries:
"up_follower_at": video.get("up_follower_at"),
"up_follower_backfilled": bool(video.get("up_follower_backfilled") or 0),
"cover": normalize_cover(video.get("cover")),
"up_face": normalize_cover(video.get("up_face")),
"folder_id": video.get("folder_id"),
"folder_title": video.get("folder_title"),
"folder_year": video.get("folder_year"),
@@ -1074,7 +1075,10 @@ class DashboardQueries:
"up_mid": mid,
"up_name": video.get("up_name") or f"UP {mid}",
"videos": [],
"face": None,
})
if group["face"] is None and video.get("up_face"):
group["face"] = video.get("up_face")
metrics = _metric_map(snapshots.get(int(video["aid"])))
group["videos"].append((video, metrics))
items = []
@@ -1105,6 +1109,8 @@ class DashboardQueries:
items.append({
"up_mid": group["up_mid"],
"up_name": group["up_name"],
"up_face": normalize_cover(group["face"]),
"follower_latest": None,
"video_count": len(group_videos),
"total_views": total_views,
"avg_views": round(total_views / len(metrics_list), 1) if metrics_list else None,
@@ -1166,6 +1172,20 @@ class DashboardQueries:
if minutes > 0 else None
)
mids = [item["up_mid"] for item in items]
if mids:
placeholders = ",".join("?" for _ in mids)
profile_rows = conn.execute(
f"SELECT mid, follower_latest FROM up_profile "
f"WHERE mid IN ({placeholders})",
mids,
).fetchall()
followers = {
int(row["mid"]): row["follower_latest"] for row in profile_rows
}
for item in items:
item["follower_latest"] = followers.get(item["up_mid"])
items = [item for item in items if item["video_count"] >= min_videos]
sort_map = {
"views": lambda item: item["total_views"],
@@ -1256,6 +1276,9 @@ class DashboardQueries:
return {
"up_mid": mid,
"up_name": items[0].get("up_name") or f"UP {mid}",
"up_face": next(
(item["up_face"] for item in items if item.get("up_face")), None
),
"video_count": len(items),
"total_views": total_views,
"avg_views": round(total_views / len(metrics_list), 1) if metrics_list else None,