use size in stead of count to prevent unnecessary querying

This commit is contained in:
Reinier Balt 2013-04-22 11:11:53 +02:00
parent caec4f214a
commit a987ff3727
5 changed files with 13 additions and 8 deletions

View file

@ -1,7 +1,7 @@
<%-
url_array = Array.new(13){ |i| url_for :controller => 'stats', :action => 'actions_done_last_years'}
created_count_array = Array.new(13){ |i| @actions_created_last12months.count/12.0 }
done_count_array = Array.new(13){ |i| @actions_done_last12months.count/12.0 }
created_count_array = Array.new(13){ |i| @actions_created_last12months.size/12.0 }
done_count_array = Array.new(13){ |i| @actions_done_last12months.size/12.0 }
month_names = Array.new(13){ |i| t('date.month_names')[ (Time.now.mon - i -1 ) % 12 + 1 ]}
-%>
&title=<%= t('stats.actions_lastyear_title') %>,{font-size:16},&

View file

@ -1,6 +1,6 @@
<%-
created_count_array = Array.new(30){ |i| @actions_created_last30days.count/30.0 }
done_count_array = Array.new(30){ |i| @actions_done_last30days.count/30.0 }
created_count_array = Array.new(30){ |i| @actions_created_last30days.size/30.0 }
done_count_array = Array.new(30){ |i| @actions_done_last30days.size/30.0 }
# TODO: make the strftime i18n proof
time_labels = Array.new(30){ |i| l(Time.zone.now-i.days, :format => :stats) }
-%>

View file

@ -1,6 +1,6 @@
<%-
created_count_array = Array.new(@month_count+1){ |i| @actions_created_last_months.count/@month_count }
done_count_array = Array.new(@month_count+1){ |i| @actions_done_last_months.count/@month_count }
created_count_array = Array.new(@month_count+1){ |i| @actions_created_last_months.size/@month_count }
done_count_array = Array.new(@month_count+1){ |i| @actions_done_last_months.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}
-%>
&title=<%= t('stats.actions_last_year') %>,{font-size:16},&