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

+15 -2
View File
@@ -422,6 +422,7 @@ class Repository:
duration: int | None = None,
pages: int | None = None,
cover: str | None = None,
up_face: str | None = None,
source: str = "manual",
now: int | None = None,
) -> IngestOutcome:
@@ -441,9 +442,9 @@ class Repository:
conn.execute(
"""
INSERT INTO video(aid, bvid, title, up_mid, up_name, pubdate,
duration, pages, cover, folder_id, fav_time, status,
duration, pages, cover, up_face, folder_id, fav_time, status,
source, first_seen, last_sync, attr)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, NULL, 'active', ?, ?, ?, 0)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, NULL, 'active', ?, ?, ?, 0)
ON CONFLICT(aid) DO UPDATE SET
bvid = COALESCE(excluded.bvid, video.bvid),
title = CASE
@@ -459,6 +460,7 @@ class Repository:
duration = COALESCE(excluded.duration, video.duration),
pages = COALESCE(excluded.pages, video.pages),
cover = COALESCE(excluded.cover, video.cover),
up_face = COALESCE(excluded.up_face, video.up_face),
status = 'active',
source = COALESCE(video.source, excluded.source),
last_sync = excluded.last_sync
@@ -473,6 +475,7 @@ class Repository:
None if duration is None else int(duration),
None if pages is None else int(pages),
cover,
up_face,
source,
now,
now,
@@ -488,6 +491,16 @@ class Repository:
)
return self.db.write(run)
def apply_video_up_face(self, aid: int, face: str | None) -> None:
"""用 ``view`` 返回的 UP 头像刷新视频行;仅在变化时写入。"""
if not isinstance(face, str) or not face.strip():
return
face = face.strip()
self.db.write(lambda conn: conn.execute(
"UPDATE video SET up_face = ? WHERE aid = ? AND (up_face IS NULL OR up_face != ?)",
(face, int(aid), face),
))
# ------------------------------------------------------- up profile
def apply_up_follower(