1
0
Fork 0
mirror of synced 2024-10-02 10:08:09 +13:00
budibase/packages/builder/cypress/support/queryLevelTransformerFunctionWithData.js

32 lines
676 B
JavaScript
Raw Normal View History

2022-01-20 00:42:11 +13:00
// eslint-disable-next-line
const breweries = data
const totals = {}
2022-01-20 00:42:11 +13:00
for (let brewery of breweries) {
const state = brewery.state
if (totals[state] == null) {
totals[state] = 1
} else {
totals[state]++
}
}
2022-01-20 00:42:11 +13:00
const stateCodes = {
texas: "tx",
colorado: "co",
florida: "fl",
iwoa: "ia",
louisiana: "la",
california: "ca",
pennsylvania: "pa",
georgia: "ga",
"new hampshire": "nh",
virginia: "va",
michigan: "mi",
maryland: "md",
ohio: "oh",
}
const entries = Object.entries(totals)
2022-01-20 00:42:11 +13:00
return entries.map(([state, count]) => {
stateCodes[state.toLowerCase()]
return { state, count, flag: "http://flags.ox3.in/svg/us/${stateCode}.svg" }
})