fix(influxdb): fixes bug with empty tagColumn for annotations

This commit is contained in:
bergquist 2016-12-15 10:54:22 +01:00
parent 51c4385c92
commit 6a161216de
2 changed files with 49 additions and 23 deletions

View File

@ -89,7 +89,7 @@ function (_, TableModel) {
if (column === 'sequence_number') { return; }
if (!titleCol) { titleCol = index; }
if (column === self.annotation.titleColumn) { titleCol = index; return; }
if (_.includes(self.annotation.tagsColumn.replace(' ', '').split(","), column)) { tagsCol.push(index); return; }
if (_.includes((self.annotation.tagsColumn || '').replace(' ', '').split(","), column)) { tagsCol.push(index); return; }
if (column === self.annotation.textColumn) { textCol = index; return; }
});

View File

@ -208,30 +208,56 @@ describe('when generating timeseries from influxdb response', function() {
});
describe('given annotation response', function() {
var options = {
alias: '',
annotation: {
tagsColumn: 'datacenter, source'
},
series: [
{
name: "logins.count",
tags: {datacenter: 'Africa', server: 'server2'},
columns: ["time", "datacenter", "hostname", "source", "value"],
values: [
[1481549440372, "America", "10.1.100.10", "backend", 215.7432653659507],
]
}
]
};
describe('with empty tagsColumn', function() {
var options = {
alias: '',
annotation: {},
series: [
{
name: "logins.count",
tags: {datacenter: 'Africa', server: 'server2'},
columns: ["time", "datacenter", "hostname", "source", "value"],
values: [
[1481549440372, "America", "10.1.100.10", "backend", 215.7432653659507],
]
}
]
};
it('should multiple tags', function() {
var series = new InfluxSeries(options);
var annotations = series.getAnnotations();
it('should multiple tags', function() {
var series = new InfluxSeries(options);
var annotations = series.getAnnotations();
expect(annotations[0].tags.length).to.be(2);
expect(annotations[0].tags[0]).to.be('America');
expect(annotations[0].tags[1]).to.be('backend');
expect(annotations[0].tags.length).to.be(0);
});
});
describe('given annotation response', function() {
var options = {
alias: '',
annotation: {
tagsColumn: 'datacenter, source'
},
series: [
{
name: "logins.count",
tags: {datacenter: 'Africa', server: 'server2'},
columns: ["time", "datacenter", "hostname", "source", "value"],
values: [
[1481549440372, "America", "10.1.100.10", "backend", 215.7432653659507],
]
}
]
};
it('should multiple tags', function() {
var series = new InfluxSeries(options);
var annotations = series.getAnnotations();
expect(annotations[0].tags.length).to.be(2);
expect(annotations[0].tags[0]).to.be('America');
expect(annotations[0].tags[1]).to.be('backend');
});
});
});
});