v1.3.3: 자체 최소 통계 및 스플래시 localStorage 정리
- 일별 익명 방문자 해시·사이트/게시물 통계(030 마이그레이션) - POST /api/analytics/pageview, 관리자 analytics API, 클라이언트 트래커 - 관리자 대시보드 통계 카드·인기 게시물 Top 5 - 스플래시: SITE_BRAND_LOGO_TEXT localStorage 제거
This commit is contained in:
35
db/migrations/030_analytics_daily_stats.sql
Normal file
35
db/migrations/030_analytics_daily_stats.sql
Normal file
@@ -0,0 +1,35 @@
|
||||
CREATE TABLE IF NOT EXISTS site_analytics_daily (
|
||||
day DATE PRIMARY KEY,
|
||||
page_views INTEGER NOT NULL DEFAULT 0,
|
||||
visitors INTEGER NOT NULL DEFAULT 0
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS post_analytics_daily (
|
||||
day DATE NOT NULL,
|
||||
post_id UUID NOT NULL REFERENCES posts(id) ON DELETE CASCADE,
|
||||
views INTEGER NOT NULL DEFAULT 0,
|
||||
reads INTEGER NOT NULL DEFAULT 0,
|
||||
visitors INTEGER NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (day, post_id)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS post_analytics_daily_day_idx
|
||||
ON post_analytics_daily (day DESC);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS analytics_daily_visitors (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
day DATE NOT NULL,
|
||||
scope TEXT NOT NULL,
|
||||
post_id UUID REFERENCES posts(id) ON DELETE CASCADE,
|
||||
visitor_hash TEXT NOT NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
CONSTRAINT analytics_daily_visitors_scope_check CHECK (scope IN ('site', 'post'))
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS analytics_daily_visitors_site_uidx
|
||||
ON analytics_daily_visitors (day, visitor_hash)
|
||||
WHERE scope = 'site';
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS analytics_daily_visitors_post_uidx
|
||||
ON analytics_daily_visitors (day, post_id, visitor_hash)
|
||||
WHERE scope = 'post';
|
||||
Reference in New Issue
Block a user