Class: BackersByPeriod

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/backers_by_period.rb

Class Method Summary collapse

Class Method Details

.chartObject



2
3
4
5
6
7
8
# File 'app/models/backers_by_period.rb', line 2

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