I can group users by count in each month like this:
User.group('year(created_at)').group('month(created_at)').count
#=> {[2015, 4]=>90, [2015, 5]=>133, [2015, 6]=>131, [2015, 7]=>28, [2015, 8]=>45, [2015, 9]=>6}
I want to create stats, showing how users count was growing by months.
So it would return something like this:
{[2015, 4]=>20, [2015, 5]=>40, [2015, 6]=>55, [2015, 7]=>70, [2015, 8]=>100, [2015, 9]=>130}
# each entry is a year, month and total users count from the beginning of time by the end of this month.
How would I get the wanted result?
I am looking for a database level solution (ActiveRecord query) if possible.
Any suggestions are appreciated.