feat: Implement map analytics system with effectiveness tracking
Add complete map analytics pipeline to answer: "Which maps drive the most players? Is my rotation working?" Backend Changes: - Migration 005: Add map_id FK to server_stats and wipe_history tables - Stats consumer now captures current_map_id when persisting stats - Map analytics queries: get_map_analytics() returns performance metrics, effectiveness scores, and rotation health - API endpoint: GET /api/analytics/maps?range=90d returns summary with best performing map and rotation effectiveness percentage Frontend Changes: - MapAnalyticsView.vue: Complete dashboard with performance charts, sortable metrics table, actionable insights, and CSV export - ECharts bar chart comparing avg vs peak players per map - Color-coded effectiveness scoring (green ≥80%, yellow ≥60%, red <60%) - Time range selector: 30d/90d/all Purpose: Enables data-driven map selection for wipe day based on player engagement metrics. Rotation effectiveness algorithm scores maps by (avg_players / peak_players) * 100. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
15
backend/migrations/005_map_analytics.sql
Normal file
15
backend/migrations/005_map_analytics.sql
Normal file
@@ -0,0 +1,15 @@
|
||||
-- Map Analytics — Add FK tracking for map effectiveness metrics
|
||||
-- Phase 2.2 Feature: Track which maps drive player count and rotation effectiveness
|
||||
|
||||
-- Add map_id to server_stats to correlate player counts with specific maps
|
||||
ALTER TABLE server_stats ADD COLUMN map_id UUID REFERENCES map_library(id) ON DELETE SET NULL;
|
||||
CREATE INDEX idx_server_stats_map ON server_stats(map_id);
|
||||
|
||||
-- Migrate wipe_history from string to FK (preserve legacy data for backward compat)
|
||||
ALTER TABLE wipe_history ADD COLUMN map_id UUID REFERENCES map_library(id) ON DELETE SET NULL;
|
||||
ALTER TABLE wipe_history RENAME COLUMN map_used TO map_used_legacy;
|
||||
CREATE INDEX idx_wipe_history_map ON wipe_history(map_id);
|
||||
|
||||
COMMENT ON COLUMN server_stats.map_id IS 'FK to map_library — tracks which map was active when stats were recorded';
|
||||
COMMENT ON COLUMN wipe_history.map_id IS 'FK to map_library — tracks which map was used for this wipe';
|
||||
COMMENT ON COLUMN wipe_history.map_used_legacy IS 'Legacy string-based map name (preserved from pre-005 data)';
|
||||
Reference in New Issue
Block a user