mirror of
https://github.com/supabase/supabase.git
synced 2026-05-09 02:09:50 -04:00
7ed8ab83a8
## I have read the [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) file. YES ## What kind of change does this PR introduce? This introduces Query Insights. It's the first edition of possible future updates. This takes our old prototype and builds upon it for a more action driven insights view. --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: Ali Waseem <waseema393@gmail.com>
22 lines
939 B
TypeScript
22 lines
939 B
TypeScript
import { useMemo } from 'react'
|
|
|
|
import type { QueryPerformanceRow } from '../../QueryPerformance/QueryPerformance.types'
|
|
import type { ClassifiedQuery } from '../QueryInsightsHealth/QueryInsightsHealth.types'
|
|
import { getQueryType } from '../QueryInsightsTable/QueryInsightsTable.utils'
|
|
import { classifyQuery } from './useQueryInsightsIssues.utils'
|
|
|
|
export function useQueryInsightsIssues(data: QueryPerformanceRow[]) {
|
|
return useMemo(() => {
|
|
const classified: ClassifiedQuery[] = data.map((row) => {
|
|
const { issueType, hint } = classifyQuery(row)
|
|
return { ...row, issueType, hint, queryType: getQueryType(row.query) }
|
|
})
|
|
|
|
const errors = classified.filter((q) => q.issueType === 'error')
|
|
const indexIssues = classified.filter((q) => q.issueType === 'index')
|
|
const slowQueries = classified.filter((q) => q.issueType === 'slow')
|
|
|
|
return { classified, errors, indexIssues, slowQueries }
|
|
}, [data])
|
|
}
|