Last active
December 22, 2015 05:58
-
-
Save diogob/6427386 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BackersByPeriod < ActiveRecord::Base | |
def self.chart | |
self.all.reduce([]) do |memo, row| | |
memo << {name: I18n.t("adm.statistics.backers_by_week.#{row.series}"), data: {}} unless memo.last && memo.last[:name] == I18n.t("adm.statistics.backers_by_week.#{row.series}") | |
memo.last[:data][Date.today - (row[:week] * 7).days] = row[:sum] | |
memo | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment