From b5868d5c704ff71c85d772ca9b61ff8ea2dc47f5 Mon Sep 17 00:00:00 2001 From: Katrina Owen Date: Thu, 28 Feb 2013 22:00:23 -0500 Subject: [PATCH] Use tag cloud objects in view This allows us to not set the individual instance variables for the tag cloud attributes. --- app/controllers/stats_controller.rb | 12 ++---------- app/views/stats/_tags.html.erb | 14 +++++++------- app/views/stats/index.html.erb | 4 ++-- 3 files changed, 11 insertions(+), 19 deletions(-) diff --git a/app/controllers/stats_controller.rb b/app/controllers/stats_controller.rb index cdfdfb46..f218c9b6 100644 --- a/app/controllers/stats_controller.rb +++ b/app/controllers/stats_controller.rb @@ -552,16 +552,8 @@ class StatsController < ApplicationController end def get_stats_tags - cloud = Stats::TagCloud.new(current_user) - - @tags_for_cloud = cloud.tags - @tags_min = cloud.min - @tags_divisor = cloud.divisor - - cloud = Stats::TagCloud.new(current_user, @cut_off_3months) - @tags_for_cloud_90days = cloud.tags - @tags_min_90days = cloud.min - @tags_divisor_90days = cloud.divisor + @tag_cloud = Stats::TagCloud.new(current_user) + @tag_cloud_90days = Stats::TagCloud.new(current_user, @cut_off_3months) end def get_ids_from (actions, week_from, week_to, at_end) diff --git a/app/views/stats/_tags.html.erb b/app/views/stats/_tags.html.erb index e1f53f83..7025e118 100755 --- a/app/views/stats/_tags.html.erb +++ b/app/views/stats/_tags.html.erb @@ -3,12 +3,12 @@

<%= t('stats.tag_cloud_description') %>

- <% if @tags_for_cloud.size < 1 + <% if tag_cloud.tags.size < 1 t('stats.no_tags_available') else - @tags_for_cloud.each do |t| %> + tag_cloud.tags.each do |t| %> <%= link_to t.name, tag_path(t.name), { - :style => "font-size: " + (9 + 2*(t.count.to_i-@tags_min)/@tags_divisor).to_s + "pt", + :style => "font-size: " + (9 + 2*(t.count.to_i-tag_cloud.min)/tag_cloud.divisor).to_s + "pt", :title => t.count.to_s+" #{t('common.actions_midsentence', :count => t.count)}"} -%> <% end @@ -20,15 +20,15 @@

<%= t('stats.tag_cloud_90days_title') %>

<%= t('stats.tag_cloud_90days_description') %>

- <% if @tags_for_cloud_90days.size < 1 + <% if tag_cloud_90days.tags.size < 1 t('stats.no_tags_available') else - @tags_for_cloud_90days.each do |t| %> + tag_cloud_90days.tags.each do |t| %> <%= link_to t.name, tag_path(t.name), { - :style => "font-size: " + (9 + 2*(t.count.to_i-@tags_min_90days)/@tags_divisor_90days).to_s + "pt", + :style => "font-size: " + (9 + 2*(t.count.to_i-tag_cloud_90days.min)/tag_cloud_90days.divisor).to_s + "pt", :title => t.count.to_s+" #{t('common.actions_midsentence', :count => t.count)}"} -%> <% end end-%>

- \ No newline at end of file + diff --git a/app/views/stats/index.html.erb b/app/views/stats/index.html.erb index 7470731e..d54b0219 100755 --- a/app/views/stats/index.html.erb +++ b/app/views/stats/index.html.erb @@ -15,7 +15,7 @@ <%= render :partial => 'projects' -%>

<%= t('stats.tags') %>

- <%= render :partial => 'tags' -%> + <%= render :partial => 'tags', :locals => {:tag_cloud => @tag_cloud, :tag_cloud_90days => @tag_cloud_90days} -%> <% else -%> @@ -23,4 +23,4 @@ <% end -%> - \ No newline at end of file +