mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-29 18:27:06 -05:00
Add admin-only database statistics dashboard - Introduces types for database statistics and recent additions - Implements hooks to fetch statistics and recent additions via RPCs - Adds UI components for stats cards and a recent additions table - Integrates new AdminDatabaseStats page and routing under /admin/database-stats - Updates admin sidebar and app routes to expose the new dashboard - Enables real-time updates and export capabilities for recent additions
22 lines
659 B
TypeScript
22 lines
659 B
TypeScript
import { useQuery } from '@tanstack/react-query';
|
|
import { supabase } from '@/integrations/supabase/client';
|
|
import { queryKeys } from '@/lib/queryKeys';
|
|
import type { DatabaseStatistics } from '@/types/database-stats';
|
|
|
|
export function useAdminDatabaseStats() {
|
|
return useQuery({
|
|
queryKey: queryKeys.admin.databaseStats(),
|
|
queryFn: async () => {
|
|
const { data, error } = await supabase.rpc('get_database_statistics');
|
|
|
|
if (error) {
|
|
throw error;
|
|
}
|
|
|
|
return data as unknown as DatabaseStatistics;
|
|
},
|
|
staleTime: 5 * 60 * 1000, // 5 minutes
|
|
refetchInterval: 60 * 1000, // Auto-refetch every 60 seconds
|
|
});
|
|
}
|