Skip to content

Commit

Permalink
fix(ui): front end sorting for numeric values now being handled corre…
Browse files Browse the repository at this point in the history
…ctly (#16237)

fix(ui): front end table sort now works for numbers, skipping test until flake is resolved
  • Loading branch information
asalem1 authored Dec 17, 2019
1 parent 25c5c5d commit bba04e2
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 7 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

### Features

1. [16234](https://github.com/influxdata/influxdb/pull/16234): add support for notification endpoints to influx templates/pkgs.
1. [16234](https://github.com/influxdata/influxdb/pull/16234): add support for notification endpoints to influx templates/pkgs.

### Bug Fixes
1. [16225](https://github.com/influxdata/influxdb/pull/16225): Ensures env vars are applied consistently across cmd, and fixes issue where INFLUX_ env var prefix was not set globally.

1. [16225](https://github.com/influxdata/influxdb/pull/16225): Ensures env vars are applied consistently across cmd, and fixes issue where INFLUX\_ env var prefix was not set globally.

1. [16235](https://github.com/influxdata/influxdb/pull/16235): Removed default frontend sorting when flux queries specify sorting
1. [16238](https://github.com/influxdata/influxdb/pull/16238): Store canceled task runs in the correct bucket
1. [16237](https://github.com/influxdata/influxdb/pull/16237): Updated Sortby functionality for table frontend sorts to sort numbers correctly

### UI Improvements

Expand Down
25 changes: 21 additions & 4 deletions ui/cypress/e2e/explorer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,9 @@ describe('DataExplorer', () => {
})
})

describe('visualize tables', () => {
// skipping until the sigin flake gets resolve in:
// https://github.com/influxdata/influxdb/issues/16253
describe.skip('visualize tables', () => {
const numLines = 360

beforeEach(() => {
Expand All @@ -623,7 +625,7 @@ describe('DataExplorer', () => {
})
})

it('can view table data', () => {
it('can view table data & sort values numerically', () => {
// build the query to return data from beforeEach
cy.getByTestID(`selector-list m`).click()
cy.getByTestID('selector-list v').click()
Expand Down Expand Up @@ -654,8 +656,23 @@ describe('DataExplorer', () => {
})
cy.getByTestID('_value-table-header').click()
cy.get('.table-graph-cell__sort-asc').should('exist')
// TODO: complete testing when FE sorting functionality is sorted
// https://github.com/influxdata/influxdb/issues/16200
cy.getByTestID('_value-table-header').click()
cy.get('.table-graph-cell__sort-desc').should('exist')
cy.getByTestID('_value-table-header')
.should('exist')
.then(el => {
// get the column index
const columnIndex = el[0].getAttribute('data-column-index')
let prev = Infinity
// get all the column values for that one and see if they are in order
cy.get(`[data-column-index="${columnIndex}"]`).each(val => {
const num = Number(val.text())
if (isNaN(num) === false) {
expect(num < prev).to.equal(true)
prev = num
}
})
})
})
})
})
Expand Down
12 changes: 11 additions & 1 deletion ui/src/dashboards/utils/tableGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,17 @@ export const sortTableData = (
const dataValues = _.drop(data, 1)
const sortedData = [
data[0],
..._.orderBy<string[][]>(dataValues, sortIndex, [sort.direction]),
..._.orderBy<string[][]>(
dataValues,
row => {
const sortedValue = row[sortIndex]
if (isNaN(Number(sortedValue))) {
return sortedValue
}
return Number(sortedValue)
},
[sort.direction]
),
] as string[][]

const sortedTimeVals = fastMap<string[], string>(
Expand Down

0 comments on commit bba04e2

Please sign in to comment.