You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 7, 2026. It is now read-only.
feat(story): track and display per-story view counts
Phase 2 PR-2A. Adds Story.viewCount with session-deduped tracking and
surfaces it everywhere a story is shown.
Schema:
- New Story.viewCount Int @default(0)
- Migration 20260421083000_add_story_view_count already applied to
the production Neon DB before this commit
Tracking:
- recordStoryView server action: simple increment, no auth required
(anonymous reads count too)
- New ViewTracker client component fires once per session per story
via sessionStorage dedupe — refreshing the same tab won't re-count,
a new tab/session will. Failures silently roll back the dedupe key
so a transient network error doesn't permanently mute counting.
- Mounted at the bottom of StoryReader
Display:
- Story detail header now shows reading time estimate (300 字/min)
and view count alongside chapter / word count
- StoryCard footer shows views next to word/chapter counts
- Feed, profile (own + drafts + liked), and public author page all
thread viewCount through their card mappers
Reading-time estimate is intentionally simple (wordCount / 300) and
clamps to a minimum of 1 minute. Will refine if user feedback says
it's off for English-heavy stories.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments