From 681bfd35a4914e86ec329dc682c0f4ea8379e689 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Fri, 12 Dec 2014 14:48:51 +0100 Subject: Limit the number of tags we show. Display the 50 most popular tags from the past 30 days. This should be a fair compromise between most popular and most recent, I hope. We may have to tune this further, but it's at least better than showing all. This is a fix for issue #56. --- .../controllers/refinery/pages_controller_decorator.rb | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/decorators/controllers/refinery/pages_controller_decorator.rb b/app/decorators/controllers/refinery/pages_controller_decorator.rb index d93ae9d..0d9a966 100644 --- a/app/decorators/controllers/refinery/pages_controller_decorator.rb +++ b/app/decorators/controllers/refinery/pages_controller_decorator.rb @@ -18,7 +18,8 @@ ApplicationController.class_eval do # on every page. # find_all_blog_categories - find_tags + #find_tags + calc_tags end def populate_home_page @@ -28,4 +29,18 @@ ApplicationController.class_eval do .where(:refinery_blog_categories => { :sidebar_position => 0 }) .page(params[:page]) end + + def calc_tags + # Limit the number of tags to show: + # This should show the 50 most popular tags from the past 30 days. + # I think this is a fair compromise between most popular and recent. + + opts = { + :order => 'count DESC', + :start_at => 30.days.ago, + :limit => 50 + } + + @tags = Refinery::Blog::Post.tag_counts_on(:tags, opts) + end end -- cgit v1.2.3