QueryPerformance.tsx35 lines · main
| 1 | import { useParams } from 'common' |
| 2 | import { useEffect } from 'react' |
| 3 | |
| 4 | import { PresetHookResult } from '../Reports/Reports.utils' |
| 5 | import { QueryPerformanceInfiniteHook } from './useQueryPerformanceQuery' |
| 6 | import { WithStatements } from './WithStatements/WithStatements' |
| 7 | import { useDatabaseSelectorStateSnapshot } from '@/state/database-selector' |
| 8 | |
| 9 | interface QueryPerformanceProps { |
| 10 | queryHitRate: PresetHookResult |
| 11 | queryPerformanceQuery: QueryPerformanceInfiniteHook |
| 12 | queryMetrics: PresetHookResult |
| 13 | } |
| 14 | |
| 15 | export const QueryPerformance = ({ |
| 16 | queryHitRate, |
| 17 | queryPerformanceQuery, |
| 18 | queryMetrics, |
| 19 | }: QueryPerformanceProps) => { |
| 20 | const { ref } = useParams() |
| 21 | const state = useDatabaseSelectorStateSnapshot() |
| 22 | |
| 23 | useEffect(() => { |
| 24 | state.setSelectedDatabaseId(ref) |
| 25 | // eslint-disable-next-line react-hooks/exhaustive-deps |
| 26 | }, [ref]) |
| 27 | |
| 28 | return ( |
| 29 | <WithStatements |
| 30 | queryHitRate={queryHitRate} |
| 31 | queryPerformanceQuery={queryPerformanceQuery} |
| 32 | queryMetrics={queryMetrics} |
| 33 | /> |
| 34 | ) |
| 35 | } |