wau = {
const lastSunday = addDays(new Date(), -(new Date()).getDay())
const rangeStart = addDays(lastSunday, (-7 * WEEK_SPAN) + 1)
const url =
`https://funfunautomator.herokuapp.com/wau` +
`?start=${dateIso8601(rangeStart)}&end=${dateIso8601(lastSunday)}`
return fetch(url)
.then(response => response.json())
.then(rows => rows.map(row => ({value: row[0], year: row[1], week: row[2] })))
.then(weeks => weeks.reduce((weekMap, week) => {
const key = firstDateOfWeekISO8601(week.year, week.week)
weekMap[key] = weekMap[key] ? weekMap[key] + week.value : week.value
return weekMap
}, {}))
.then(weekMap => Object.keys(weekMap).map(key => ({
date: key,
value: weekMap[key]
})))
}