budibase/packages/builder/cypress/support/queryLevelTransformerFuncti...

15 lines
321 B
JavaScript
Raw Normal View History

2022-01-19 12:42:11 +01:00
// eslint-disable-next-line
const breweries = data
const totals = {}
2022-01-19 12:42:11 +01:00
for (let brewery of breweries) {
const state = brewery.state
if (totals[state] == null) {
totals[state] = 1
} else {
totals[state]++
}
}
const entries = Object.entries(totals)
return entries.map(([state, count]) => ({ state, count }))