mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 23:30:12 +01:00
Moving label creation to helpers
This commit is contained in:
parent
5b045d2c1a
commit
845ac14176
4 changed files with 18 additions and 12 deletions
|
|
@ -36,7 +36,6 @@ 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| label_for_month_ago(i) }
|
||||
render :layout => false
|
||||
end
|
||||
|
||||
|
|
@ -48,14 +47,6 @@ 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)
|
||||
|
|
@ -85,7 +76,6 @@ 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| label_for_month_and_year_ago(i) }
|
||||
|
||||
render :layout => false
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,4 +4,20 @@ module StatsHelper
|
|||
9 + 2 * cloud.relative_size(tag)
|
||||
end
|
||||
|
||||
def month_and_year_label(i)
|
||||
t('date.month_names')[ (Time.now.mon - i -1 ) % 12 + 1 ]+ " " + (Time.now - i.months).year.to_s
|
||||
end
|
||||
|
||||
def array_of_month_and_year_labels(count)
|
||||
Array.new(count) { |i| month_and_year_label(i) }
|
||||
end
|
||||
|
||||
def month_label(i)
|
||||
t('date.month_names')[ (Time.now.mon - i -1 ) % 12 + 1 ]
|
||||
end
|
||||
|
||||
def array_of_month_labels(count)
|
||||
Array.new(count) { |i| month_label(i) }
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
&values_6=<%= @actions_done_avg_last12months_array.join(",")%>&
|
||||
&values_7=<%= @interpolated_actions_created_this_month%>,<%=@actions_done_avg_last12months_array[1]%>&
|
||||
&values_8=<%= @interpolated_actions_done_this_month%>,<%=@actions_created_avg_last12months_array[1]%>&
|
||||
&x_labels=<%= @month_names.join(",")%>&
|
||||
&x_labels=<%= array_of_month_labels(@done_count_array.size).join(",")%>&
|
||||
&y_min=0&
|
||||
<% # add one to @max for people who have no actions completed yet.
|
||||
# OpenFlashChart cannot handle y_max=0 -%>
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
&values_6=<%= @actions_done_avg_last_months_array.join(",")%>&
|
||||
&values_7=<%= @interpolated_actions_created_this_month%>,<%=@actions_done_avg_last_months_array[1]%>&
|
||||
&values_8=<%= @interpolated_actions_done_this_month%>,<%=@actions_created_avg_last_months_array[1]%>&
|
||||
&x_labels=<%= @month_names.join(",")%>&
|
||||
&x_labels=<%= array_of_month_and_year_labels(@done_count_array.size).join(",")%>&
|
||||
&y_min=0&
|
||||
<% # add one to @max for people who have no actions completed yet.
|
||||
# OpenFlashChart cannot handle y_max=0 -%>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue