fix: sorting logic is updated (#2882)

* fix: sorting logic is updated

* fix: made a util for error rate

* chore: updated the function name
This commit is contained in:
Palash Gupta 2023-06-12 18:19:07 +05:30 committed by GitHub
parent bd6745dd66
commit ef74ef3526
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View File

@ -11,6 +11,8 @@ import { useParams } from 'react-router-dom';
import { AppState } from 'store/reducers';
import { GlobalReducer } from 'types/reducer/globalTime';
import { getErrorRate } from './utils';
function TopOperationsTable(props: TopOperationsTableProps): JSX.Element {
const { minTime, maxTime } = useSelector<AppState, GlobalReducer>(
(state) => state.globalTime,
@ -89,10 +91,10 @@ function TopOperationsTable(props: TopOperationsTableProps): JSX.Element {
dataIndex: 'errorCount',
key: 'errorCount',
width: 50,
sorter: (a: TopOperationList, b: TopOperationList): number =>
a.errorCount - b.errorCount,
render: (value: number, record: TopOperationList): string =>
`${((value / record.numCalls) * 100).toFixed(2)} %`,
sorter: (first: TopOperationList, second: TopOperationList): number =>
getErrorRate(first) - getErrorRate(second),
render: (_, record: TopOperationList): string =>
`${getErrorRate(record).toFixed(2)} %`,
},
];

View File

@ -0,0 +1,4 @@
import { TopOperationList } from './TopOperationsTable';
export const getErrorRate = (list: TopOperationList): number =>
(list.errorCount / list.numCalls) * 100;