perf: consolidate 7 dashboard hooks into single batch request
Replace useDashboardOverview, useDashboardPages, useDashboardLocations, useDashboardDevices, useDashboardReferrers, useDashboardPerformance, and useDashboardGoals with a single useDashboard hook that calls the existing /dashboard batch endpoint. This endpoint runs all queries in parallel on the backend and caches the result in Redis (30s TTL). Reduces dashboard requests from 12 to 6 per refresh cycle (50% reduction). At 1,000 concurrent users: ~6,000 req/min instead of 12,000.
This commit is contained in:
@@ -245,8 +245,8 @@ export interface DashboardData {
|
||||
goal_counts?: GoalCountStat[]
|
||||
}
|
||||
|
||||
export function getDashboard(siteId: string, startDate?: string, endDate?: string, limit = 10, interval?: string): Promise<DashboardData> {
|
||||
return apiRequest<DashboardData>(`/sites/${siteId}/dashboard${buildQuery({ startDate, endDate, limit, interval })}`)
|
||||
export function getDashboard(siteId: string, startDate?: string, endDate?: string, limit = 10, interval?: string, filters?: string): Promise<DashboardData> {
|
||||
return apiRequest<DashboardData>(`/sites/${siteId}/dashboard${buildQuery({ startDate, endDate, limit, interval, filters })}`)
|
||||
}
|
||||
|
||||
export function getPublicDashboard(
|
||||
|
||||
Reference in New Issue
Block a user