fix parameter format

This commit is contained in:
Mitsuhiro Tanda 2017-09-24 12:25:52 +09:00
parent fe1d395d79
commit 8243ac39c2
3 changed files with 12 additions and 15 deletions

View File

@ -87,7 +87,7 @@ func (e *CloudWatchExecutor) executeTimeSeriesQuery(ctx context.Context, queryCo
}
currentlyExecuting++
go func(refId string, index int) {
queryRes, err := e.executeQuery(ctx, queryContext.Queries[index].Model.Get("parameters"), queryContext)
queryRes, err := e.executeQuery(ctx, queryContext.Queries[index].Model, queryContext)
currentlyExecuting--
if err != nil {
errCh <- err

View File

@ -48,14 +48,13 @@ function (angular, _, moment, dateMath, kbn, templatingVariable, CloudWatchAnnot
item.dimensions = dimensions;
item.period = self.getPeriod(item, options);
return {
return _.extend({
refId: item.refId,
intervalMs: options.intervalMs,
maxDataPoints: options.maxDataPoints,
datasourceId: self.instanceSettings.id,
type: 'timeSeriesQuery',
parameters: item
};
}, item);
});
// No valid targets, return the empty result to save a round trip.
@ -147,15 +146,14 @@ function (angular, _, moment, dateMath, kbn, templatingVariable, CloudWatchAnnot
from: range.from,
to: range.to,
queries: [
{
_.extend({
refId: 'metricFindQuery',
intervalMs: 1, // dummy
maxDataPoints: 1, // dummy
datasourceId: this.instanceSettings.id,
type: 'metricFindQuery',
subtype: subtype,
parameters: parameters
}
subtype: subtype
}, parameters)
]
}).then(function (r) { return transformSuggestDataFromTable(r); });
};

View File

@ -1,4 +1,3 @@
import "../datasource";
import {describe, beforeEach, it, expect, angularMocks} from 'test/lib/common';
import helpers from 'test/specs/helpers';
@ -76,11 +75,11 @@ describe('CloudWatchDatasource', function() {
it('should generate the correct query', function(done) {
ctx.ds.query(query).then(function() {
var params = requestParams.queries[0];
expect(params.parameters.namespace).to.be(query.targets[0].namespace);
expect(params.parameters.metricName).to.be(query.targets[0].metricName);
expect(params.parameters.dimensions['InstanceId']).to.be('i-12345678');
expect(params.parameters.statistics).to.eql(query.targets[0].statistics);
expect(params.parameters.period).to.be(query.targets[0].period);
expect(params.namespace).to.be(query.targets[0].namespace);
expect(params.metricName).to.be(query.targets[0].metricName);
expect(params.dimensions['InstanceId']).to.be('i-12345678');
expect(params.statistics).to.eql(query.targets[0].statistics);
expect(params.period).to.be(query.targets[0].period);
done();
});
ctx.$rootScope.$apply();
@ -110,7 +109,7 @@ describe('CloudWatchDatasource', function() {
ctx.ds.query(query).then(function() {
var params = requestParams.queries[0];
expect(params.parameters.period).to.be(600);
expect(params.period).to.be(600);
done();
});
ctx.$rootScope.$apply();