import { Response } from 'express'; import { AuthRequest } from '../middleware/auth'; import * as analyticsService from '../services/analyticsService'; /** Returns full admin dashboard analytics for the selected filters. */ export async function getDashboardAnalytics(req: AuthRequest, res: Response): Promise { try { const preset = typeof req.query.preset === 'string' ? req.query.preset : undefined; const from = typeof req.query.from === 'string' ? req.query.from : undefined; const to = typeof req.query.to === 'string' ? req.query.to : undefined; const gameKey = typeof req.query.gameKey === 'string' ? req.query.gameKey : undefined; const data = await analyticsService.getAdminDashboardAnalytics({ preset, from, to, gameKey }); res.json(data); } catch (e) { const msg = e instanceof Error ? e.message : 'Failed to load dashboard analytics'; res.status(400).json({ error: msg }); } }