Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with mislabeled scripted field filters from histogram #4751

Merged
merged 1 commit into from
Aug 31, 2015
Merged
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
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();
});
});
});