mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-22 22:51:13 -05:00
Enhance admin stats dashboard
Add data quality metrics, growth trends visualization, entity comparison views, and automated health checks to the AdminDatabaseStats dashboard, including new TS types, hooks, UI components, and integrated tabbed layout.
This commit is contained in:
21
src/hooks/useDatabaseHealthCheck.ts
Normal file
21
src/hooks/useDatabaseHealthCheck.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { supabase } from '@/integrations/supabase/client';
|
||||
import { queryKeys } from '@/lib/queryKeys';
|
||||
import type { DatabaseHealthData } from '@/types/database-analytics';
|
||||
|
||||
export function useDatabaseHealthCheck() {
|
||||
return useQuery({
|
||||
queryKey: queryKeys.analytics.databaseHealth(),
|
||||
queryFn: async () => {
|
||||
const { data, error } = await supabase.rpc('check_database_health');
|
||||
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
return data as unknown as DatabaseHealthData;
|
||||
},
|
||||
staleTime: 5 * 60 * 1000, // 5 minutes
|
||||
refetchInterval: 2 * 60 * 1000, // Auto-refetch every 2 minutes (health is important!)
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user