import { Lightbulb } from 'lucide-react' import { useEffect, useState } from 'react' import { formatSql } from 'lib/formatSql' import { AlertDescription_Shadcn_, AlertTitle_Shadcn_, Alert_Shadcn_, Button, CodeBlock, cn, } from 'ui' import { QueryPanelContainer, QueryPanelSection } from './QueryPanel' import { QUERY_PERFORMANCE_REPORTS, QUERY_PERFORMANCE_REPORT_TYPES, } from './QueryPerformance.constants' interface QueryDetailProps { reportType: QUERY_PERFORMANCE_REPORT_TYPES selectedRow: any onClickViewSuggestion: () => void } export const QueryDetail = ({ reportType, selectedRow, onClickViewSuggestion, }: QueryDetailProps) => { // [Joshen] TODO implement this logic once the linter rules are in const isLinterWarning = false const report = QUERY_PERFORMANCE_REPORTS[reportType] const [query, setQuery] = useState(selectedRow?.['query']) useEffect(() => { if (selectedRow !== undefined) { const formattedQuery = formatSql(selectedRow['query']) setQuery(formattedQuery) } }, [selectedRow]) return (

Query pattern

code]:m-0 [&>code>span]:flex [&>code>span]:flex-wrap' )} /> {isLinterWarning && ( Suggested optimization: Add an index Adding an index will help this query execute faster )}
{report .filter((x) => x.id !== 'query') .map((x) => { const isTime = x.name.includes('time') const formattedValue = isTime ? `${selectedRow?.[x.id].toFixed(2)}ms` : String(selectedRow?.[x.id]) return (

{x.name}

{formattedValue}

) })}
) }