From cb6e99a710d6a56ce1db41ce0d93ff7f5fa4955d Mon Sep 17 00:00:00 2001 From: Nathan L Smith Date: Fri, 16 Oct 2020 09:19:33 -0500 Subject: [PATCH] Fix error rate sorting in services list (#80764) (#80789) The field was incorrectly labeled `errorsPerMinute` instead of `transactionErrorRate` (probably left over from before when we switched to using error rate.) Use `-1` for the fallback sort so "N/A" appears after "0%" Fixes #80473. --- .../app/ServiceOverview/ServiceList/index.tsx | 12 +++++++----- .../ServiceList/service_list.test.tsx | 2 -- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/x-pack/plugins/apm/public/components/app/ServiceOverview/ServiceList/index.tsx b/x-pack/plugins/apm/public/components/app/ServiceOverview/ServiceList/index.tsx index 49319f167703c6..0ce07a3c0ad27f 100644 --- a/x-pack/plugins/apm/public/components/app/ServiceOverview/ServiceList/index.tsx +++ b/x-pack/plugins/apm/public/components/app/ServiceOverview/ServiceList/index.tsx @@ -153,7 +153,7 @@ export const SERVICE_COLUMNS: Array> = [ width: px(unit * 10), }, { - field: 'errorsPerMinute', + field: 'transactionErrorRate', name: i18n.translate('xpack.apm.servicesTable.transactionErrorRate', { defaultMessage: 'Error rate %', }), @@ -222,13 +222,15 @@ export function ServiceList({ items, noItemsMessage }: Props) { itemsToSort, (item) => { switch (sortField) { + // Use `?? -1` here so `undefined` will appear after/before `0`. + // In the table this will make the "N/A" items always at the + // bottom/top. case 'avgResponseTime': - return item.avgResponseTime?.value ?? 0; + return item.avgResponseTime?.value ?? -1; case 'transactionsPerMinute': - return item.transactionsPerMinute?.value ?? 0; + return item.transactionsPerMinute?.value ?? -1; case 'transactionErrorRate': - return item.transactionErrorRate?.value ?? 0; - + return item.transactionErrorRate?.value ?? -1; default: return item[sortField as keyof typeof item]; } diff --git a/x-pack/plugins/apm/public/components/app/ServiceOverview/ServiceList/service_list.test.tsx b/x-pack/plugins/apm/public/components/app/ServiceOverview/ServiceList/service_list.test.tsx index daddd0a60fe1f1..73777c2221a5b1 100644 --- a/x-pack/plugins/apm/public/components/app/ServiceOverview/ServiceList/service_list.test.tsx +++ b/x-pack/plugins/apm/public/components/app/ServiceOverview/ServiceList/service_list.test.tsx @@ -35,8 +35,6 @@ describe('ServiceList', () => { it('renders with data', () => { expect(() => - // Types of property 'avgResponseTime' are incompatible. - // Type 'null' is not assignable to type '{ value: number | null; timeseries: { x: number; y: number | null; }[]; } | undefined'.ts(2322) renderWithTheme( , { wrapper: Wrapper }