Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
npm-debug.log
.idea
13 changes: 11 additions & 2 deletions dist/datasource.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ function (angular, _, dateMath, moment) {
var intervals = getQueryIntervals(from, to);
var promise = null;

var skipEmptyBuckets = target.skipEmptyBuckets

var selectMetrics = target.selectMetrics;
var selectDimensions = target.selectDimensions;
var selectThreshold = target.selectThreshold;
Expand Down Expand Up @@ -187,7 +189,8 @@ function (angular, _, dateMath, moment) {
});
}
else {
promise = this._timeSeriesQuery(datasource, intervals, granularity, filters, aggregators, postAggregators)

promise = this._timeSeriesQuery(datasource, intervals, granularity, filters, aggregators, postAggregators,skipEmptyBuckets)
.then(function(response) {
return convertTimeSeriesData(response.data, metricNames);
});
Expand Down Expand Up @@ -237,7 +240,7 @@ function (angular, _, dateMath, moment) {
return this._druidQuery(query);
};

this._timeSeriesQuery = function (datasource, intervals, granularity, filters, aggregators, postAggregators) {
this._timeSeriesQuery = function (datasource, intervals, granularity, filters, aggregators, postAggregators, skipEmptyBuckets) {
var query = {
"queryType": "timeseries",
"dataSource": datasource,
Expand All @@ -247,6 +250,12 @@ function (angular, _, dateMath, moment) {
"intervals": intervals
};

if(skipEmptyBuckets){
query.context = {
"skipEmptyBuckets": "true"
}
}

if (filters && filters.length > 0) {
query.filter = buildFilterTree(filters);
}
Expand Down
4 changes: 4 additions & 0 deletions dist/partials/query.editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@
</select>
</div>
</div>

<gf-form-switch class="gf-form" label="Custom Granularity" label-class="query-keyword" checked="ctrl.target.shouldOverrideGranularity" on-change="ctrl.targetBlur()">
</gf-form-switch>

<gf-form-switch class="gf-form" label="Skip empty buckets" ng-if="ctrl.target.queryType == 'timeseries'" label-class="query-keyword" checked="ctrl.target.skipEmptyBuckets" on-change="ctrl.targetBlur()">
</gf-form-switch>

<div class="gf-form" ng-hide="!ctrl.target.shouldOverrideGranularity">
<div class="gf-form-select-wrapper max-width-15">
<select ng-model="ctrl.target.customGranularity" class="gf-form-input" ng-options="granularity for granularity in ctrl.customGranularity" ng-change="ctrl.targetBlur()">
Expand Down
13 changes: 11 additions & 2 deletions src/datasource.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ function (angular, _, dateMath, moment) {
var intervals = getQueryIntervals(from, to);
var promise = null;

var skipEmptyBuckets = target.skipEmptyBuckets

var selectMetrics = target.selectMetrics;
var selectDimensions = target.selectDimensions;
var selectThreshold = target.selectThreshold;
Expand Down Expand Up @@ -187,7 +189,8 @@ function (angular, _, dateMath, moment) {
});
}
else {
promise = this._timeSeriesQuery(datasource, intervals, granularity, filters, aggregators, postAggregators)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RestfulBlue, just a minor comment to remove this space.

promise = this._timeSeriesQuery(datasource, intervals, granularity, filters, aggregators, postAggregators,skipEmptyBuckets)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need a space between , and skipEmptyBuckets.

.then(function(response) {
return convertTimeSeriesData(response.data, metricNames);
});
Expand Down Expand Up @@ -237,7 +240,7 @@ function (angular, _, dateMath, moment) {
return this._druidQuery(query);
};

this._timeSeriesQuery = function (datasource, intervals, granularity, filters, aggregators, postAggregators) {
this._timeSeriesQuery = function (datasource, intervals, granularity, filters, aggregators, postAggregators, skipEmptyBuckets) {
var query = {
"queryType": "timeseries",
"dataSource": datasource,
Expand All @@ -247,6 +250,12 @@ function (angular, _, dateMath, moment) {
"intervals": intervals
};

if(skipEmptyBuckets){
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please indent this piece correctly following the current indentation.

query.context = {
"skipEmptyBuckets": "true"
}
}

if (filters && filters.length > 0) {
query.filter = buildFilterTree(filters);
}
Expand Down
4 changes: 4 additions & 0 deletions src/partials/query.editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@
</select>
</div>
</div>

<gf-form-switch class="gf-form" label="Custom Granularity" label-class="query-keyword" checked="ctrl.target.shouldOverrideGranularity" on-change="ctrl.targetBlur()">
</gf-form-switch>

<gf-form-switch class="gf-form" label="Skip empty buckets" ng-if="ctrl.target.queryType == 'timeseries'" label-class="query-keyword" checked="ctrl.target.skipEmptyBuckets" on-change="ctrl.targetBlur()">
</gf-form-switch>

<div class="gf-form" ng-hide="!ctrl.target.shouldOverrideGranularity">
<div class="gf-form-select-wrapper max-width-15">
<select ng-model="ctrl.target.customGranularity" class="gf-form-input" ng-options="granularity for granularity in ctrl.customGranularity" ng-change="ctrl.targetBlur()">
Expand Down