()
| 47 | |
| 48 | // Manual trigger function |
| 49 | const triggerAnalysis = async () => { |
| 50 | if (!file || !currentFileId || loadingRef.current || isAnalyzing) { |
| 51 | return; |
| 52 | } |
| 53 | |
| 54 | loadingRef.current = true; |
| 55 | setIsLoading(true); |
| 56 | setError(null); |
| 57 | |
| 58 | try { |
| 59 | console.log('[useColumnStats] Manual analysis triggered for:', file.fileName); |
| 60 | |
| 61 | const tableName = file.tableName; |
| 62 | if (!tableName) { |
| 63 | throw new Error('Table name not found for file'); |
| 64 | } |
| 65 | |
| 66 | await analyzeFile(currentFileId, tableName); |
| 67 | |
| 68 | console.log('[useColumnStats] Manual analysis completed successfully'); |
| 69 | } catch (err) { |
| 70 | console.error('[useColumnStats] Manual analysis failed:', err); |
| 71 | setError(err instanceof Error ? err.message : 'Failed to load column statistics'); |
| 72 | } finally { |
| 73 | loadingRef.current = false; |
| 74 | setIsLoading(false); |
| 75 | } |
| 76 | }; |
| 77 | |
| 78 | useEffect(() => { |
| 79 | // Reset state when file changes |
no outgoing calls
no test coverage detected