Переглянути джерело

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

Torkel Ödegaard 10 роки тому
батько
коміт
37ff432f9d

+ 2 - 1
CHANGELOG.md

@@ -6,7 +6,7 @@
 * **InfluxDB**: Support for policy selection in query editor, closes [#2018](https://github.com/grafana/grafana/issues/2018)
 
 ### 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)
 * **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 @@
 
 ### Bug fixes
 * **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)
 

+ 6 - 2
public/app/plugins/datasource/influxdb/influx_series.js

@@ -133,14 +133,18 @@ function (_, TableModel) {
       if (series.values) {
         for (i = 0; i < series.values.length; i++) {
           var values = series.values[i];
+          var reordered = [values[0]];
           if (series.tags) {
             for (var key in series.tags) {
               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);
         }
       }
     });

+ 5 - 5
public/app/plugins/datasource/influxdb/specs/influx_series_specs.ts

@@ -189,9 +189,9 @@ describe('when generating timeseries from influxdb response', function() {
       series: [
         {
           name: 'app.prod.server1.count',
-          tags:  {},
-          columns: ['time', 'datacenter', 'value'],
-          values: [[1431946625000, 'America', 10], [1431946626000, 'EU', 12]]
+          tags:  {datacenter: 'Africa', server: 'server2'},
+          columns: ['time', 'value2', 'value'],
+          values: [[1431946625000, 23, 10], [1431946626000, 25, 12]]
         }
       ]
     };
@@ -201,8 +201,8 @@ describe('when generating timeseries from influxdb response', function() {
       var table = series.getTable();
 
       expect(table.type).to.be('table');
-      expect(table.columns.length).to.be(3);
-      expect(table.rows[0]).to.eql([1431946625000, 'America', 10]);
+      expect(table.columns.length).to.be(5);
+      expect(table.rows[0]).to.eql([1431946625000, 'Africa', 'server2', 23, 10]);
     });
   });