mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 08:51:13 -05:00
Implements edge function, Django tasks, and UI hooks/panels for automatic retention of old metrics, anomalies, alerts, and incidents, plus updates to query keys and monitoring dashboard to reflect data-retention workflows.
102 lines
4.4 KiB
TypeScript
102 lines
4.4 KiB
TypeScript
/**
|
|
* Centralized query key definitions for TanStack Query
|
|
*
|
|
* This ensures consistent query keys across the application
|
|
* and makes cache invalidation easier to manage.
|
|
*/
|
|
|
|
export const queryKeys = {
|
|
// User-related queries
|
|
userRoles: (userId?: string) => ['user-roles', userId] as const,
|
|
userPermissions: (userId?: string) => ['user-permissions', userId] as const,
|
|
|
|
// Moderation queue queries
|
|
moderationQueue: (config: Record<string, any>) => ['moderation-queue', config] as const,
|
|
moderationStats: () => ['moderation-stats'] as const,
|
|
|
|
// Homepage queries
|
|
homepage: {
|
|
trendingParks: () => ['homepage', 'trending-parks'] as const,
|
|
trendingRides: () => ['homepage', 'trending-rides'] as const,
|
|
recentParks: () => ['homepage', 'recent-parks'] as const,
|
|
recentRides: () => ['homepage', 'recent-rides'] as const,
|
|
recentChanges: () => ['homepage', 'recent-changes'] as const,
|
|
recentlyOpenedParks: () => ['homepage', 'recently-opened-parks'] as const,
|
|
recentlyOpenedRides: () => ['homepage', 'recently-opened-rides'] as const,
|
|
highestRatedParks: () => ['homepage', 'highest-rated-parks'] as const,
|
|
highestRatedRides: () => ['homepage', 'highest-rated-rides'] as const,
|
|
openingSoonParks: () => ['homepage', 'opening-soon-parks'] as const,
|
|
openingSoonRides: () => ['homepage', 'opening-soon-rides'] as const,
|
|
closingSoonParks: () => ['homepage', 'closing-soon-parks'] as const,
|
|
closingSoonRides: () => ['homepage', 'closing-soon-rides'] as const,
|
|
recentlyClosedParks: () => ['homepage', 'recently-closed-parks'] as const,
|
|
recentlyClosedRides: () => ['homepage', 'recently-closed-rides'] as const,
|
|
featuredParks: {
|
|
topRated: () => ['homepage', 'featured-parks', 'top-rated'] as const,
|
|
mostRides: () => ['homepage', 'featured-parks', 'most-rides'] as const,
|
|
},
|
|
},
|
|
|
|
// Parks queries
|
|
parks: {
|
|
all: () => ['parks', 'all'] as const,
|
|
detail: (slug: string) => ['parks', 'detail', slug] as const,
|
|
rides: (parkId: string) => ['parks', 'rides', parkId] as const,
|
|
},
|
|
|
|
// Rides queries
|
|
rides: {
|
|
all: () => ['rides', 'all'] as const,
|
|
detail: (parkSlug: string, rideSlug: string) => ['rides', 'detail', parkSlug, rideSlug] as const,
|
|
similar: (parkId: string, category: string, currentId: string) =>
|
|
['rides', 'similar', parkId, category, currentId] as const,
|
|
},
|
|
|
|
// Reviews queries
|
|
reviews: {
|
|
entity: (entityType: 'park' | 'ride', entityId: string) =>
|
|
['reviews', entityType, entityId] as const,
|
|
user: (userId: string, filter: string, sortBy: string) =>
|
|
['reviews', 'user', userId, filter, sortBy] as const,
|
|
},
|
|
|
|
// Photos queries
|
|
photos: {
|
|
entity: (entityType: string, entityId: string) =>
|
|
['photos', entityType, entityId] as const,
|
|
count: (entityType: string, entityId: string) =>
|
|
['photos', 'count', entityType, entityId] as const,
|
|
},
|
|
|
|
// Search queries
|
|
search: {
|
|
global: (query: string) => ['search', 'global', query] as const,
|
|
},
|
|
|
|
// Lists queries
|
|
lists: {
|
|
items: (listId: string) => ['list-items', listId] as const,
|
|
},
|
|
|
|
// Monitoring queries
|
|
monitoring: {
|
|
overview: () => ['monitoring', 'overview'] as const,
|
|
systemHealth: () => ['system-health'] as const,
|
|
systemAlerts: (severity?: string) => ['system-alerts', severity] as const,
|
|
rateLimitStats: (timeWindow: number) => ['rate-limit-stats', timeWindow] as const,
|
|
recentErrors: (timeWindow: number) => ['recent-errors', timeWindow] as const,
|
|
recentActivity: (timeWindow: number) => ['recent-activity', timeWindow] as const,
|
|
combinedAlerts: () => ['monitoring', 'combined-alerts'] as const,
|
|
databaseHealth: () => ['monitoring', 'database-health'] as const,
|
|
moderationHealth: () => ['monitoring', 'moderation-health'] as const,
|
|
groupedAlerts: (options?: { includeResolved?: boolean; minCount?: number; severity?: string }) =>
|
|
['monitoring', 'grouped-alerts', options] as const,
|
|
alertGroupDetails: (groupKey: string) => ['monitoring', 'alert-group-details', groupKey] as const,
|
|
correlatedAlerts: () => ['monitoring', 'correlated-alerts'] as const,
|
|
incidents: (status?: string) => ['monitoring', 'incidents', status] as const,
|
|
incidentDetails: (incidentId: string) => ['monitoring', 'incident-details', incidentId] as const,
|
|
anomalyDetections: () => ['monitoring', 'anomaly-detections'] as const,
|
|
dataRetentionStats: () => ['monitoring', 'data-retention-stats'] as const,
|
|
},
|
|
} as const;
|