Skip to content

Commit

Permalink
Merge branch 'master' into 5481/log_bool_values
Browse files Browse the repository at this point in the history
  • Loading branch information
sranka authored Aug 24, 2020
2 parents ada6797 + fdaf9f2 commit 33ff2fc
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
1. [#5551](https://github.com/influxdata/chronograf/pull/5551): Sort namespaces by database and retention policy.
1. [#5556](https://github.com/influxdata/chronograf/pull/5556): Make MySQL protoboard more useful by using derivatives for counter values.
1. [#5536](https://github.com/influxdata/chronograf/pull/5536): Add HTTP security headers.
1. [#5553](https://github.com/influxdata/chronograf/pull/5553): Show all query results in table view.
1. [#5555](https://github.com/influxdata/chronograf/pull/5555): Show also boolean field/tag values in tickscript editor logs.

### Other
Expand Down
33 changes: 24 additions & 9 deletions ui/src/utils/groupByTimeSeriesTransform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,9 @@ const constructTimeSeries = (
serieses: Series[],
cells: Cells,
sortedLabels: Label[],
seriesLabels: Label[][]
seriesLabels: Label[][],
allowDuplicateTime = false
): TimeSeries[] => {
const nullArray: TimeSeriesValue[] = Array(sortedLabels.length).fill(null)

const labelsToValueIndex = fastReduce<Label, {[x: string]: number}>(
sortedLabels,
(acc, {label, responseIndex, seriesIndex}, i) => {
Expand Down Expand Up @@ -382,23 +381,38 @@ const constructTimeSeries = (
}

existingRowIndex = tsMemo[time]
const valueIndex = labelsToValueIndex[label + responseIndex + seriesIndex]

// avoid memoizing null time columns for meta queries
if (existingRowIndex === undefined || time === null) {
// + optionally create a duplicate entry if it would overwrite existing
if (
existingRowIndex === undefined ||
time === null ||
(allowDuplicateTime &&
existingRowIndex !== undefined &&
timeSeries[existingRowIndex].values[valueIndex] !== undefined)
) {
timeSeries.push({
time,
values: fastCloneArray(nullArray),
values: new Array(sortedLabels.length),
})

existingRowIndex = timeSeries.length - 1
tsMemo[time] = existingRowIndex
}

timeSeries[existingRowIndex].values[
labelsToValueIndex[label + responseIndex + seriesIndex]
] = value
timeSeries[existingRowIndex].values[valueIndex] = value
}

// change all undefined values to null, these values were not set
timeSeries.forEach(x => {
for (let i = 0; i < x.values.length; i++) {
if (x.values[i] === undefined) {
x.values[i] = null
}
}
})

return _.sortBy(timeSeries, 'time')
}

Expand Down Expand Up @@ -434,7 +448,8 @@ export const groupByTimeSeriesTransform = (
serieses,
cells,
sortedLabels,
seriesLabels
seriesLabels,
isTable
)
return {
sortedLabels,
Expand Down
38 changes: 38 additions & 0 deletions ui/test/utils/timeSeriesTransformers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,44 @@ describe('timeSeriesToTableGraph', () => {
expect(actual.data).toEqual(expected)
expect(actual.influxQLQueryType).toEqual(InfluxQLQueryType.MetaQuery)
})
it('returns all table results even with duplicate time rows #5502', () => {
const influxResponse = [
{
response: {
results: [
{
statement_id: 0,
series: [
{
name: 'mem',
columns: ['time', 'host', 'val'],
values: [
[1000, 'a', 1],
[1000, 'b', 2],
[2000, 'b', 3],
[2000, 'c', 4],
],
},
],
},
],
uuid: '8cb3862f-aacf-4c3a-990f-4479de00ff99',
},
},
]

const actual = timeSeriesToTableGraph(influxResponse)
const expected = [
['time', 'mem.host', 'mem.val'],
[1000, 'a', 1],
[1000, 'b', 2],
[2000, 'b', 3],
[2000, 'c', 4],
]

expect(actual.data).toEqual(expected)
expect(actual.influxQLQueryType).toEqual(InfluxQLQueryType.DataQuery)
})
})

describe('filterTableColumns', () => {
Expand Down

0 comments on commit 33ff2fc

Please sign in to comment.