Class: StatsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/stats_controller.rb

Instance Method Summary collapse

Instance Method Details

#monthObject



3
4
5
6
7
8
9
10
11
12
# File 'app/controllers/stats_controller.rb', line 3

def month
  @mode = :month

  year = params[:year].to_i
  month = params[:month].to_i
  @month = Date.new(year, month)
  @stat = make_month_stats(@month)

  render :show
end

#recentObject



25
26
27
28
29
30
31
32
33
# File 'app/controllers/stats_controller.rb', line 25

def recent
  @mode = :recent

  now = DateTime.now.beginning_of_month
  months = (0...12).map{|i| now << i}.reverse
  @stat = make_year_stats(months)

  render :show
end

#yearObject



14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/stats_controller.rb', line 14

def year
  @mode = :year

  year = params[:year].to_i
  @year = Date.new(year)
  months = (0...12).map{|i| @year >> i}
  @stat = make_year_stats(months)

  render :show
end