mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
Not setting the value correctly when the agg value is zero
This commit is contained in:
parent
097996bd5c
commit
1187abf636
5 changed files with 14 additions and 8 deletions
|
@ -60,7 +60,10 @@ define(function (require) {
|
|||
|
||||
var _record = _.flatten([record, bucket.key]);
|
||||
_.each(metrics, function (metric) {
|
||||
var value = bucket[metric.id] && bucket[metric.id].value || bucket.doc_count;
|
||||
var value = bucket.doc_count;
|
||||
if (bucket[metric.id] && !_.isUndefined(bucket[metric.id].value)) {
|
||||
value = bucket[metric.id].value;
|
||||
}
|
||||
_record.push(value);
|
||||
});
|
||||
|
||||
|
|
|
@ -5,7 +5,10 @@ define(function (require) {
|
|||
return _.map(extractBuckets(aggData), function (bucket) {
|
||||
// Pick the appropriate value, if the metric doesn't exist then we just
|
||||
// use the count.
|
||||
var value = bucket[metric.id] && bucket[metric.id].value || bucket.doc_count;
|
||||
var value = bucket.doc_count;
|
||||
if (bucket[metric.id] && !_.isUndefined(bucket[metric.id].value)) {
|
||||
value = bucket[metric.id].value;
|
||||
}
|
||||
|
||||
// Create the new branch record
|
||||
var branch = {
|
||||
|
|
|
@ -25,8 +25,8 @@ define(function (require) {
|
|||
agg_1: { value: 9299 },
|
||||
agg_4: {
|
||||
buckets: [
|
||||
{ key: 'win', doc_count: 4, agg_1: { value: 4992 } },
|
||||
{ key: 'mac', doc_count: 6, agg_1: { value: 5892 } }
|
||||
{ key: 'win', doc_count: 4, agg_1: { value: 0 } },
|
||||
{ key: 'mac', doc_count: 6, agg_1: { value: 9299 } }
|
||||
]
|
||||
}
|
||||
},
|
||||
|
|
|
@ -60,8 +60,8 @@ define(function (require) {
|
|||
it('should have rows set', function () {
|
||||
expect(results).to.have.property('rows');
|
||||
expect(results.rows).to.eql([
|
||||
['png', 412032, 'IT', 9299, 'win', 4992],
|
||||
['png', 412032, 'IT', 9299, 'mac', 5892],
|
||||
['png', 412032, 'IT', 9299, 'win', 0],
|
||||
['png', 412032, 'IT', 9299, 'mac', 9299],
|
||||
['png', 412032, 'US', 8293, 'linux', 3992],
|
||||
['png', 412032, 'US', 8293, 'mac', 3029],
|
||||
['css', 412032, 'MX', 9299, 'win', 4992],
|
||||
|
|
|
@ -33,7 +33,7 @@ define(function (require) {
|
|||
var agg = { id: 'agg_2', name: 'test' };
|
||||
var aggData = {
|
||||
buckets: [
|
||||
{ key: 'foo', doc_count: 1, agg_1: { value: 3 } },
|
||||
{ key: 'foo', doc_count: 1, agg_1: { value: 0 } },
|
||||
{ key: 'bar', doc_count: 2, agg_1: { value: 4 } }
|
||||
]
|
||||
};
|
||||
|
@ -41,7 +41,7 @@ define(function (require) {
|
|||
var children = tranform(agg, fixture.metric, aggData);
|
||||
expect(children).to.be.an(Array);
|
||||
expect(children).to.have.length(2);
|
||||
expect(children[0]).to.have.property('size', 3);
|
||||
expect(children[0]).to.have.property('size', 0);
|
||||
expect(children[1]).to.have.property('size', 4);
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue