Commit 37ff432f by Torkel Ödegaard

fix(influxdb): fix for influxdb when using format as table and having group by time, fixes #2928

parent 80e15dd7
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* **InfluxDB**: Support for policy selection in query editor, closes [#2018](https://github.com/grafana/grafana/issues/2018) * **InfluxDB**: Support for policy selection in query editor, closes [#2018](https://github.com/grafana/grafana/issues/2018)
### Breaking changes ### Breaking changes
* **Plugin API**: Both datasource and panel plugin api (and plugin.json schema) have been updated, requiring a minor update to plugins. See [plugin api](https://github.com/grafana/grafana/blob/master/public/app/plugins/plugin_api.md) for more info. * **Plugin API**: Both datasource and panel plugin api (and plugin.json schema) have been updated, requiring an update to plugins. See [plugin api](https://github.com/grafana/grafana/blob/master/public/app/plugins/plugin_api.md) for more info.
* **InfluxDB 0.8.x** The data source for the old version of influxdb (0.8.x) is no longer included in default builds, but can easily be installed via improved plugin system, closes [#3523](https://github.com/grafana/grafana/issues/3523) * **InfluxDB 0.8.x** The data source for the old version of influxdb (0.8.x) is no longer included in default builds, but can easily be installed via improved plugin system, closes [#3523](https://github.com/grafana/grafana/issues/3523)
* **KairosDB** The data source is no longer included in default builds, but can easily be installed via improved plugin system, closes [#3524](https://github.com/grafana/grafana/issues/3524) * **KairosDB** The data source is no longer included in default builds, but can easily be installed via improved plugin system, closes [#3524](https://github.com/grafana/grafana/issues/3524)
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
### Bug fixes ### Bug fixes
* **Playlist**: Fix for memory leak when running a playlist, closes [#3794](https://github.com/grafana/grafana/pull/3794) * **Playlist**: Fix for memory leak when running a playlist, closes [#3794](https://github.com/grafana/grafana/pull/3794)
* **InfluxDB**: Fix for InfluxDB and table panel when using Format As Table and having group by time, fixes [#3928](https://github.com/grafana/grafana/pull/3928)
# 2.6.1 (unrelased, 2.6.x branch) # 2.6.1 (unrelased, 2.6.x branch)
......
...@@ -133,14 +133,18 @@ function (_, TableModel) { ...@@ -133,14 +133,18 @@ function (_, TableModel) {
if (series.values) { if (series.values) {
for (i = 0; i < series.values.length; i++) { for (i = 0; i < series.values.length; i++) {
var values = series.values[i]; var values = series.values[i];
var reordered = [values[0]];
if (series.tags) { if (series.tags) {
for (var key in series.tags) { for (var key in series.tags) {
if (series.tags.hasOwnProperty(key)) { if (series.tags.hasOwnProperty(key)) {
values.splice(1, 0, series.tags[key]); reordered.push(series.tags[key]);
} }
} }
} }
table.rows.push(values); for (j = 1; j < values.length; j++) {
reordered.push(values[j]);
}
table.rows.push(reordered);
} }
} }
}); });
......
...@@ -189,9 +189,9 @@ describe('when generating timeseries from influxdb response', function() { ...@@ -189,9 +189,9 @@ describe('when generating timeseries from influxdb response', function() {
series: [ series: [
{ {
name: 'app.prod.server1.count', name: 'app.prod.server1.count',
tags: {}, tags: {datacenter: 'Africa', server: 'server2'},
columns: ['time', 'datacenter', 'value'], columns: ['time', 'value2', 'value'],
values: [[1431946625000, 'America', 10], [1431946626000, 'EU', 12]] values: [[1431946625000, 23, 10], [1431946626000, 25, 12]]
} }
] ]
}; };
...@@ -201,8 +201,8 @@ describe('when generating timeseries from influxdb response', function() { ...@@ -201,8 +201,8 @@ describe('when generating timeseries from influxdb response', function() {
var table = series.getTable(); var table = series.getTable();
expect(table.type).to.be('table'); expect(table.type).to.be('table');
expect(table.columns.length).to.be(3); expect(table.columns.length).to.be(5);
expect(table.rows[0]).to.eql([1431946625000, 'America', 10]); expect(table.rows[0]).to.eql([1431946625000, 'Africa', 'server2', 23, 10]);
}); });
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment