소스 검색

Revert "Conditionally select a field to return in ResponseParser for InfluxDB"

This reverts commit a101177b5521bfdd8ce67f6a60216fb7fb8d3c8f.

Ref #12009
Daniel Lee 7 년 전
부모
커밋
de7a880d66
2개의 변경된 파일4개의 추가작업 그리고 39개의 파일을 삭제
  1. 4 13
      public/app/plugins/datasource/influxdb/response_parser.ts
  2. 0 26
      public/app/plugins/datasource/influxdb/specs/response_parser.jest.ts

+ 4 - 13
public/app/plugins/datasource/influxdb/response_parser.ts

@@ -11,23 +11,14 @@ export default class ResponseParser {
       return [];
     }
 
+    var influxdb11format = query.toLowerCase().indexOf('show tag values') >= 0;
+
     var res = {};
     _.each(influxResults.series, serie => {
       _.each(serie.values, value => {
         if (_.isArray(value)) {
-          // In general, there are 2 possible shapes for the returned value.
-          // The first one is a two-element array,
-          // where the first element is somewhat a metadata value:
-          // the tag name for SHOW TAG VALUES queries,
-          // the time field for SELECT queries, etc.
-          // The second shape is an one-element array,
-          // that is containing an immediate value.
-          // For example, SHOW FIELD KEYS queries return such shape.
-          // Note, pre-0.11 versions return
-          // the second shape for SHOW TAG VALUES queries
-          // (while the newer versions—first).
-          if (value[1] !== undefined) {
-            addUnique(res, value[1]);
+          if (influxdb11format) {
+            addUnique(res, value[1] || value[0]);
           } else {
             addUnique(res, value[0]);
           }

+ 0 - 26
public/app/plugins/datasource/influxdb/specs/response_parser.jest.ts

@@ -85,32 +85,6 @@ describe('influxdb response parser', () => {
     });
   });
 
-  describe('SELECT response', () => {
-    var query = 'SELECT "usage_iowait" FROM "cpu" LIMIT 10';
-    var response = {
-      results: [
-        {
-          series: [
-            {
-              name: 'cpu',
-              columns: ['time', 'usage_iowait'],
-              values: [[1488465190006040638, 0.0], [1488465190006040638, 15.0], [1488465190006040638, 20.2]],
-            },
-          ],
-        },
-      ],
-    };
-
-    var result = parser.parse(query, response);
-
-    it('should return second column', () => {
-      expect(_.size(result)).toBe(3);
-      expect(result[0].text).toBe(0.0);
-      expect(result[1].text).toBe(15.0);
-      expect(result[2].text).toBe(20.2);
-    });
-  });
-
   describe('SHOW FIELD response', () => {
     var query = 'SHOW FIELD KEYS FROM "cpu"';
     describe('response from 0.10.0', () => {