Skip to content

Commit

Permalink
Fixing a condition where series agg might have undefined row (elastic…
Browse files Browse the repository at this point in the history
  • Loading branch information
simianhacker committed Jan 27, 2018
1 parent febcb39 commit f99bef5
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const basic = fnName => targetSeries => {
const data = [];
_.zip(...targetSeries).forEach(row => {
const key = row[0][0];
const values = row.map(r => r[1]);
const values = row.map(r => r && r[1] || 0);
const fn = _[fnName] || (() => null);
data.push([key, fn(values)]);
});
Expand All @@ -21,7 +21,7 @@ const overall = fnName => targetSeries => {
const values = [];
_.zip(...targetSeries).forEach(row => {
keys.push(row[0][0]);
values.push(fn(row.map(r => r[1])));
values.push(fn(row.map(r => r && r[1] || 0)));
});
return [keys.map(k => [k, fn(values)])];
};
Expand All @@ -35,7 +35,7 @@ export default {
const data = [];
_.zip(...targetSeries).forEach(row => {
const key = row[0][0];
const values = row.map(r => r[1]);
const values = row.map(r => r && r[1] || 0);
data.push([key, mean(values)]);
});
return [data];
Expand All @@ -52,7 +52,7 @@ export default {
const values = [];
_.zip(...targetSeries).forEach(row => {
keys.push(row[0][0]);
values.push(_.sum(row.map(r => r[1])));
values.push(_.sum(row.map(r => r && r[1] || 0)));
});
return [keys.map(k => [k, fn(values)])];
},
Expand All @@ -62,7 +62,7 @@ export default {
let sum = 0;
_.zip(...targetSeries).forEach(row => {
const key = row[0][0];
sum += _.sum(row.map(r => r[1]));
sum += _.sum(row.map(r => r && r[1] || 0));
data.push([key, sum]);
});
return [data];
Expand Down

0 comments on commit f99bef5

Please sign in to comment.