feat(ov): windowed dedup visit counting with retention cleanup

Task 8 (P2): POST /public/albums/{token}/visits with visit_sessions
window dedup (VISIT_WINDOW_MINUTES), requestId idempotent replay
(echoes stored outcome; expired beyond VISIT_REQUEST_TTL_MINUTES
rejected), album_stats viewCount/statVersion authority + outbox_stat_events
views snapshots, WS stats.updated broadcast, visitorId+IP fixed-window
rate limit (VISIT_WINDOW_REQUESTS), and ov CleanupModule scheduler
(setInterval, CLEANUP_INTERVAL_MINUTES) deleting like_batches /
visit_requests / visit_sessions past their windows — totals never
touched. Contract prose aligned to replay semantics; constants
VISIT_WINDOW_REQUESTS / CLEANUP_INTERVAL_MINUTES added.

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
浅念
2026-09-18 18:14:01 +08:00
parent 85b2da3db5
commit 1f2a0c658f
14 changed files with 1398 additions and 25 deletions
+5
View File
@@ -55,3 +55,8 @@ LIKE_SESSION_WINDOW_DELTA=500
LIKE_IP_WINDOW_DELTA=2000
LIKE_BURST_MERGE_MS=500
VISIT_REQUEST_TTL_MINUTES=35
# P2 Task 8:浏览上报基础限速(visitorId+IP 固定窗,窗口=VISIT_WINDOW_MINUTES,
# 每窗请求数上限——去重本身为主缓解)与 ov 互动流水清理调度间隔(分钟,0=停用;
# 清理 like_batches/visit_requests/visit_sessions 超窗口行,累计总数永不清)。
VISIT_WINDOW_REQUESTS=60
CLEANUP_INTERVAL_MINUTES=60