mirror of
https://github.com/supabase/supabase.git
synced 2026-05-23 19:13:13 +08:00
* feat: move query details to sheet This moves the click through on Query Performance to a sheet as opposed to a resizable area. This gives us more space to play with and sets us up for the Query details revamp. * fix: tabs font size * style: expand size of sheet * feat: hasOverlay prop for sheets * feat: add optional overlay for sheets * fix: closing only when clicking outside of rows * style: width of panel on different viewports * fix: horizontal scroll for table * fix: query queries label check in metrics
48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
import React, { useMemo } from 'react'
|
|
|
|
import { Skeleton } from 'ui'
|
|
import { useQueryPerformanceQuery } from '../Reports/Reports.queries'
|
|
|
|
export const QueryPerformanceMetrics = () => {
|
|
const { data: queryMetrics, isLoading } = useQueryPerformanceQuery({
|
|
preset: 'queryMetrics',
|
|
})
|
|
|
|
const stats = useMemo(() => {
|
|
return [
|
|
{
|
|
title: queryMetrics?.[0]?.slow_queries === 1 ? 'Slow Query' : 'Slow Queries',
|
|
value: queryMetrics?.[0]?.slow_queries || '0',
|
|
},
|
|
{
|
|
title: 'Cache Hit Rate',
|
|
value: queryMetrics?.[0]?.cache_hit_rate || '0%',
|
|
},
|
|
{
|
|
title: 'Avg. Rows Per Call',
|
|
value: queryMetrics?.[0]?.avg_rows_per_call || '0',
|
|
},
|
|
]
|
|
}, [queryMetrics])
|
|
|
|
return (
|
|
<section className="px-6 pt-2 pb-4 flex flex-wrap gap-x-6 gap-y-2 w-full">
|
|
{stats.map((card, i) => (
|
|
<React.Fragment key={i}>
|
|
<div className="flex items-baseline gap-2 heading-subSection text-foreground-light">
|
|
{isLoading ? (
|
|
<Skeleton className="h-5 w-24" />
|
|
) : (
|
|
<>
|
|
<span className="text-foreground">{card.value}</span>
|
|
<span>{card.title}</span>
|
|
</>
|
|
)}
|
|
</div>
|
|
{i < stats.length - 1 && <span className="text-foreground-muted">/</span>}
|
|
</React.Fragment>
|
|
))}
|
|
</section>
|
|
)
|
|
}
|