Commit 50a10706 by Torkel Ödegaard

Graphite: Fixed issue with using series ref and series by tag, fixes #15237

parent 30f0c350
......@@ -98,7 +98,7 @@ export default class GraphiteQuery {
this.functions.push(innerFunc);
break;
case 'series-ref':
if (this.segments.length > 0) {
if (this.segments.length > 0 || this.getSeriesByTagFuncIndex() >= 0) {
this.addFunctionParameter(func, astNode.value);
} else {
this.segments.push(astNode);
......
......@@ -44,4 +44,16 @@ describe('Graphite query model', () => {
expect(ctx.queryModel.target.targetFull).toBeDefined();
});
});
describe('when query seriesByTag and series ref', () => {
beforeEach(() => {
ctx.target = { refId: 'A', target: `group(seriesByTag('namespace=asd'), #A)` };
ctx.targets = [ctx.target];
ctx.queryModel = new GraphiteQuery(ctx.datasource, ctx.target, ctx.templateSrv);
});
it('should keep group function series ref', () => {
expect(ctx.queryModel.functions[1].params[0]).toBe('#A');
});
});
});
......@@ -24,7 +24,6 @@ describe('GraphiteQueryCtrl', () => {
beforeEach(() => {
GraphiteQueryCtrl.prototype.target = ctx.target;
GraphiteQueryCtrl.prototype.datasource = ctx.datasource;
GraphiteQueryCtrl.prototype.panelCtrl = ctx.panelCtrl;
ctx.ctrl = new GraphiteQueryCtrl(
......@@ -84,22 +83,6 @@ describe('GraphiteQueryCtrl', () => {
});
});
describe('when initializing target without metric expression and only function', () => {
beforeEach(() => {
ctx.ctrl.target.target = 'asPercent(#A, #B)';
ctx.ctrl.datasource.metricFindQuery = () => Promise.resolve([]);
ctx.ctrl.parseTarget();
});
it('should not add select metric segment', () => {
expect(ctx.ctrl.segments.length).toBe(1);
});
it('should add second series ref as param', () => {
expect(ctx.ctrl.queryModel.functions[0].params.length).toBe(1);
});
});
describe('when initializing a target with single param func using variable', () => {
beforeEach(() => {
ctx.ctrl.target.target = 'movingAverage(prod.count, $var)';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment