mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-27 12:28:48 +01:00
Moving time labels to separate methods
This commit is contained in:
parent
98a9acf741
commit
3babc05a2d
1 changed files with 10 additions and 2 deletions
|
|
@ -36,7 +36,7 @@ class StatsController < ApplicationController
|
|||
|
||||
@created_count_array = Array.new(13, actions_last12months.created_after(@cut_off_year).count/12.0)
|
||||
@done_count_array = Array.new(13, actions_last12months.completed_after(@cut_off_year).count/12.0)
|
||||
@month_names = Array.new(13){ |i| t('date.month_names')[ (Time.now.mon - i -1 ) % 12 + 1 ]}
|
||||
@month_names = Array.new(13){ |i| label_for_month_ago(i) }
|
||||
render :layout => false
|
||||
end
|
||||
|
||||
|
|
@ -48,6 +48,14 @@ class StatsController < ApplicationController
|
|||
Time.zone.now.day / Time.zone.now.end_of_month.day.to_f
|
||||
end
|
||||
|
||||
def label_for_month_and_year_ago(i)
|
||||
t('date.month_names')[ (Time.now.mon - i -1 ) % 12 + 1 ]+ " " + (Time.now - i.months).year.to_s
|
||||
end
|
||||
|
||||
def label_for_month_ago(i)
|
||||
t('date.month_names')[ (Time.now.mon - i -1 ) % 12 + 1 ]
|
||||
end
|
||||
|
||||
def actions_done_last_years
|
||||
@page_title = t('stats.index_title')
|
||||
@chart = Stats::Chart.new('actions_done_lastyears_data', :height => 400, :width => 900)
|
||||
|
|
@ -77,7 +85,7 @@ class StatsController < ApplicationController
|
|||
|
||||
@created_count_array = Array.new(month_count+1, actions_last_months.select { |x| x.created_at }.size/month_count)
|
||||
@done_count_array = Array.new(month_count+1, actions_last_months.select { |x| x.completed_at }.size/month_count)
|
||||
@month_names = Array.new(month_count+1){ |i| t('date.month_names')[ (Time.now.mon - i -1 ) % 12 + 1 ]+ " " + (Time.now - i.months).year.to_s}
|
||||
@month_names = Array.new(month_count+1){ |i| label_for_month_and_year_ago(i) }
|
||||
|
||||
render :layout => false
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue