Skip to content

Instantly share code, notes, and snippets.

@balthazar
Created November 16, 2017 16:25
Show Gist options
  • Save balthazar/57e4935f83d3f16b5c2194e53b60adc5 to your computer and use it in GitHub Desktop.
Save balthazar/57e4935f83d3f16b5c2194e53b60adc5 to your computer and use it in GitHub Desktop.
const dates = stars.map(o => new Date(o.starredAt))
const grouped = _.groupBy(dates, d => format(d, 'YYYY/MM/DD'))
const byDay = Object.keys(grouped).reduce((acc, date, i) => {
const count = grouped[date].length
return acc.concat({ date, stars: count, total: i === 0 ? count : count + acc[i - 1].total })
}, [])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment