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:
@@ -73,6 +73,11 @@ impl StatsConsumerService {
|
||||
// Parse JSON payload
|
||||
match serde_json::from_slice::<StatsPayload>(&msg.payload) {
|
||||
Ok(stats_payload) => {
|
||||
// Fetch current map_id for map analytics tracking
|
||||
let map_id = stats::get_current_map_id(&db, stats_payload.license_id)
|
||||
.await
|
||||
.unwrap_or(None);
|
||||
|
||||
// Persist to database
|
||||
match stats::insert_server_stats(
|
||||
&db,
|
||||
@@ -83,6 +88,7 @@ impl StatsConsumerService {
|
||||
stats_payload.entities,
|
||||
stats_payload.uptime,
|
||||
stats_payload.memory,
|
||||
map_id,
|
||||
)
|
||||
.await
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user