From f577dd0f389b69006005c7548cf679652e877c74 Mon Sep 17 00:00:00 2001 From: thuck Date: Sun, 5 Mar 2017 23:13:46 +0100 Subject: [PATCH 1/4] Including LIMIT, SLIMIT and ORDER BY time on influxdb #6065 Initial work for the query builder interface --- .../datasource/influxdb/influx_query.ts | 1 + .../influxdb/partials/query.editor.html | 24 ++++++++++++++++++- .../plugins/datasource/influxdb/query_ctrl.ts | 5 ++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/public/app/plugins/datasource/influxdb/influx_query.ts b/public/app/plugins/datasource/influxdb/influx_query.ts index 065b85cf175..89cba55773f 100644 --- a/public/app/plugins/datasource/influxdb/influx_query.ts +++ b/public/app/plugins/datasource/influxdb/influx_query.ts @@ -21,6 +21,7 @@ export default class InfluxQuery { target.policy = target.policy || 'default'; target.dsType = 'influxdb'; target.resultFormat = target.resultFormat || 'time_series'; + target.orderByTime = target.orderByTime || 'ASC'; target.tags = target.tags || []; target.groupBy = target.groupBy || [ {type: 'time', params: ['$__interval']}, diff --git a/public/app/plugins/datasource/influxdb/partials/query.editor.html b/public/app/plugins/datasource/influxdb/partials/query.editor.html index f718fbc5d29..509a0d473eb 100644 --- a/public/app/plugins/datasource/influxdb/partials/query.editor.html +++ b/public/app/plugins/datasource/influxdb/partials/query.editor.html @@ -72,11 +72,33 @@ +
+
+ +
+ +
+
+ +
+ + +
+ +
+ + +
+
+
+
+
+
- +
diff --git a/public/app/plugins/datasource/influxdb/query_ctrl.ts b/public/app/plugins/datasource/influxdb/query_ctrl.ts index 26f09d26d29..f78ed0727db 100644 --- a/public/app/plugins/datasource/influxdb/query_ctrl.ts +++ b/public/app/plugins/datasource/influxdb/query_ctrl.ts @@ -14,6 +14,7 @@ export class InfluxQueryCtrl extends QueryCtrl { queryBuilder: any; groupBySegment: any; resultFormats: any[]; + orderByTime: any[]; policySegment: any; tagSegments: any[]; selectMenu: any; @@ -32,6 +33,10 @@ export class InfluxQueryCtrl extends QueryCtrl { {text: 'Time series', value: 'time_series'}, {text: 'Table', value: 'table'}, ]; + this.orderByTime = [ + {text: 'Ascending', value: 'ASC'}, + {text: 'Descending', value: 'DESC'}, + ]; this.policySegment = uiSegmentSrv.newSegment(this.target.policy); From c3eb9da160dba67ec2f10a8850463c6a2338b297 Mon Sep 17 00:00:00 2001 From: thuck Date: Sun, 5 Mar 2017 23:41:16 +0100 Subject: [PATCH 2/4] Finish query builder for LIMIT, SLIMIT and ORDER BY time #6065 --- .../app/plugins/datasource/influxdb/influx_query.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/public/app/plugins/datasource/influxdb/influx_query.ts b/public/app/plugins/datasource/influxdb/influx_query.ts index 89cba55773f..a5e9e2ffd6a 100644 --- a/public/app/plugins/datasource/influxdb/influx_query.ts +++ b/public/app/plugins/datasource/influxdb/influx_query.ts @@ -250,6 +250,18 @@ export default class InfluxQuery { query += ' fill(' + target.fill + ')'; } + if (target.orderByTime === 'DESC') { + query += ' ORDER BY time DESC'; + } + + if (target.limit) { + query += ' LIMIT ' + target.limit; + } + + if (target.slimit) { + query += ' SLIMIT ' + target.slimit; + } + return query; } From 1cf569ac8e2589fed2c5d504c46c5c740da62cff Mon Sep 17 00:00:00 2001 From: thuck Date: Wed, 8 Mar 2017 08:25:32 +0100 Subject: [PATCH 3/4] Fix tabs vs space --- .../influxdb/partials/query.editor.html | 43 +++++++++---------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/public/app/plugins/datasource/influxdb/partials/query.editor.html b/public/app/plugins/datasource/influxdb/partials/query.editor.html index 509a0d473eb..69c1c7867f6 100644 --- a/public/app/plugins/datasource/influxdb/partials/query.editor.html +++ b/public/app/plugins/datasource/influxdb/partials/query.editor.html @@ -72,28 +72,27 @@
-
-
- -
- -
-
- -
- - -
- -
- - -
-
-
-
-
- +
+
+ +
+ +
+
+ +
+ + +
+ +
+ + +
+
+
+
+
From b8a82827b999d220f80b0060fc43302c54a81f98 Mon Sep 17 00:00:00 2001 From: thuck Date: Wed, 8 Mar 2017 20:22:01 +0100 Subject: [PATCH 4/4] Fix ORDER BY to look like GROUP BY --- .../plugins/datasource/influxdb/partials/query.editor.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/public/app/plugins/datasource/influxdb/partials/query.editor.html b/public/app/plugins/datasource/influxdb/partials/query.editor.html index 69c1c7867f6..c8848d6f43b 100644 --- a/public/app/plugins/datasource/influxdb/partials/query.editor.html +++ b/public/app/plugins/datasource/influxdb/partials/query.editor.html @@ -74,7 +74,8 @@
- + +
@@ -97,7 +98,7 @@
- +