mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 08:11:13 -05:00
Fix analyze_data_completeness and admin guard
- Add migration to fix JSONB array filtering in analyze_data_completeness - Update useDataCompleteness to run only on admin pages via isAdminPage check - Prepare for replacing invalid JSONB subtraction with proper filtering in RPCs
This commit is contained in:
@@ -6,12 +6,15 @@
|
||||
*/
|
||||
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
import { useLocation } from 'react-router-dom';
|
||||
import { supabase } from '@/integrations/supabase/client';
|
||||
import { useEffect } from 'react';
|
||||
import type { CompletenessAnalysis, CompletenessFilters } from '@/types/data-completeness';
|
||||
import { handleError } from '@/lib/errorHandler';
|
||||
|
||||
export function useDataCompleteness(filters: CompletenessFilters = {}) {
|
||||
const location = useLocation();
|
||||
const isAdminPage = location.pathname.startsWith('/admin');
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const query = useQuery({
|
||||
@@ -40,6 +43,7 @@ export function useDataCompleteness(filters: CompletenessFilters = {}) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
enabled: isAdminPage, // Only run on admin pages
|
||||
staleTime: 5 * 60 * 1000, // Cache for 5 minutes
|
||||
refetchOnWindowFocus: false,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user