mirror of
https://github.com/supabase/supabase.git
synced 2026-07-01 20:54:19 +08:00
* fix: tidy up index advisor panel * style: some paddings and spacing * nit: margins for an alert
29 lines
829 B
TypeScript
29 lines
829 B
TypeScript
import { HTMLAttributes } from 'react'
|
|
|
|
import { cn } from 'ui'
|
|
import { calculateImprovement } from './index-advisor.utils'
|
|
|
|
interface IndexImprovementTextProps extends HTMLAttributes<HTMLParagraphElement> {
|
|
indexStatements: string[]
|
|
totalCostBefore: number
|
|
totalCostAfter: number
|
|
}
|
|
|
|
export const IndexImprovementText = ({
|
|
indexStatements,
|
|
totalCostBefore,
|
|
totalCostAfter,
|
|
className,
|
|
...props
|
|
}: IndexImprovementTextProps) => {
|
|
const improvement = calculateImprovement(totalCostBefore, totalCostAfter)
|
|
|
|
return (
|
|
<p className={cn('text-sm text-foreground-light mb-3', className)} {...props}>
|
|
Query's performance can be improved by{' '}
|
|
<span className="text-brand">{improvement.toFixed(2)}%</span> by creating this{' '}
|
|
{indexStatements.length > 1 ? 'indexes' : 'index'}:
|
|
</p>
|
|
)
|
|
}
|