Skip to content

Commit

Permalink
Merge pull request #4751 from lukasolson/issues/4696
Browse files Browse the repository at this point in the history
Fix issue with mislabeled scripted field filters from histogram
  • Loading branch information
spalger committed Aug 31, 2015
2 parents 3658991 + f982bc9 commit 6cb7fec
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ describe('AggConfig Filters', function () {
expect(filter.range).to.have.property('bytes');
expect(filter.range.bytes).to.have.property('gte', 2048);
expect(filter.range.bytes).to.have.property('lt', 3072);

expect(filter.meta).to.have.property('formattedValue', '2,048');
});

});
});
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('AggConfig Filters', function () {
expect(filter.range).to.have.property('bytes');
expect(filter.range.bytes).to.have.property('gte', 1024.0);
expect(filter.range.bytes).to.have.property('lt', 2048.0);
expect(filter.meta).to.have.property('formattedValue', '1,024 to 2,048');
});

});
});
10 changes: 6 additions & 4 deletions src/ui/public/agg_types/buckets/create_filter/histogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ define(function (require) {
return function (aggConfig, key) {
var value = parseInt(key, 10);

return buildRangeFilter(aggConfig.params.field, {
gte: value,
lt: value + aggConfig.params.interval
}, aggConfig.vis.indexPattern);
return buildRangeFilter(
aggConfig.params.field,
{gte: value, lt: value + aggConfig.params.interval},
aggConfig.vis.indexPattern,
aggConfig.fieldFormatter()(key)
);
};
};
});
21 changes: 21 additions & 0 deletions src/ui/public/filter_bar/__tests__/mapScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,26 @@ describe('Filter Bar Directive', function () {
$rootScope.$apply();
});

it('should return a value for a range/histogram filter from a scripted field', (done) => {
let filter = {
meta: {
index: 'logstash-*',
formattedValue: '1,000.00 to 2,000.00',
field: 'script number'
},
script: {
params: {
gte: 1000,
lt: 2000,
value: '>=1,000.00 <2,000.00'
}
}
};
mapScript(filter).then((result) => {
expect(result).to.have.property('value', filter.meta.formattedValue);
done();
});
$rootScope.$apply();
});
});
});

0 comments on commit 6cb7fec

Please sign in to comment.