Skip to content

Instantly share code, notes, and snippets.

@diogob
Last active December 22, 2015 05:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diogob/6427386 to your computer and use it in GitHub Desktop.
Save diogob/6427386 to your computer and use it in GitHub Desktop.
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