Skip to content

Commit

Permalink
Merge branch 'fix-aggregate-example-aggregate-unpacking'
Browse files Browse the repository at this point in the history
  • Loading branch information
dhowden committed Sep 13, 2017
2 parents 8753142 + 67c9f0a commit 2838ff7
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions examples/aggregate/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,23 @@ pipeline.listen(responseUpdatedEvent, response => {
const CountAggregateFilterOptions = (response, field) => {
// Extract the aggregates from the response.
const aggs = response.getAggregates();
const countAggs = aggs[`count.${field}`]["count"]["counts"];

if (!aggs) {
return {};
}
const topLevelCount = aggs[`count.${field}`];
if (!topLevelCount) {
return {};
}
const secondLevelCount = topLevelCount["count"];
if (!secondLevelCount) {
return {};
}
const actualCounts = secondLevelCount["counts"];
if (!actualCounts) {
return {};
}
let opts = {};
Object.keys(countAggs).forEach(c => {
Object.keys(actualCounts).forEach(c => {
// Setup the name -> filter pair.
opts[c] = `${field}='${c}'`;
});
Expand Down

0 comments on commit 2838ff7

Please sign in to comment.