Skip to content

Commit

Permalink
Fix error rate sorting in services list (#80764) (#80790)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
smith authored Oct 16, 2020
1 parent 1ad01bb commit c234042
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export const SERVICE_COLUMNS: Array<ITableColumn<ServiceListItem>> = [
width: px(unit * 10),
},
{
field: 'errorsPerMinute',
field: 'transactionErrorRate',
name: i18n.translate('xpack.apm.servicesTable.transactionErrorRate', {
defaultMessage: 'Error rate %',
}),
Expand Down Expand Up @@ -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];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
<ServiceList items={props.items as ServiceListAPIResponse['items']} />,
{ wrapper: Wrapper }
Expand Down

0 comments on commit c234042

Please sign in to comment.