import {Fragment} from 'react'; import {useTheme} from '@emotion/react'; import GridEditable from 'sentry/components/gridEditable'; import {useLocation} from 'sentry/utils/useLocation'; import { DataRow, Keys, similarity, TableColumnHeader, } from 'sentry/views/starfish/modules/databaseModule/databaseTableView'; import {useQueryMainTable} from 'sentry/views/starfish/modules/databaseModule/queries'; type Props = { mainTableRow: DataRow; }; const COLUMN_ORDER: TableColumnHeader[] = [ { key: 'description', name: 'Query', width: 300, }, { key: 'epm', name: 'Tpm', }, { key: 'p50', name: 'p50', }, { key: 'p95', name: 'p95', }, { key: 'total_time', name: 'Total Time', }, ]; function SimilarQueryView(props: Props) { const {mainTableRow} = props; const {isLoading, data} = useQueryMainTable({ limit: 410, }); const location = useLocation(); const theme = useTheme(); const similarQueries = data.filter( row => similarity(row.description, mainTableRow.description) > 0.8 ); const renderHeadCell = (col): React.ReactNode => { return {col.name}; }; const renderBodyCell = (column: TableColumnHeader, row: DataRow): React.ReactNode => { const {key} = column; let renderedValue: React.ReactNode = row[key]; if (key === 'description') { const mainTableQueryWords = new Set(mainTableRow.description.split(' ')); const diffQuery = (