From b2686cc6d141cd3c08baab7d858d6ea4f6b51a6f Mon Sep 17 00:00:00 2001 From: pardoam Date: Wed, 2 Dec 2015 14:48:41 +0000 Subject: [PATCH] five_last_week --- app/controllers/concerns/commentable_actions.rb | 2 +- app/models/debate.rb | 2 +- app/models/proposal.rb | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/controllers/concerns/commentable_actions.rb b/app/controllers/concerns/commentable_actions.rb index df232069b..e04b275d1 100644 --- a/app/controllers/concerns/commentable_actions.rb +++ b/app/controllers/concerns/commentable_actions.rb @@ -64,7 +64,7 @@ module CommentableActions end def tag_cloud - resource_model.tag_counts.order("#{resource_name.pluralize}_count": :desc, name: :asc).limit(20) + resource_model.last_week.tag_counts.order("#{resource_name.pluralize}_count": :desc, name: :asc).limit(5) end def load_featured_tags diff --git a/app/models/debate.rb b/app/models/debate.rb index 086bd5ae4..7b264d036 100644 --- a/app/models/debate.rb +++ b/app/models/debate.rb @@ -34,7 +34,7 @@ class Debate < ActiveRecord::Base scope :sort_by_random, -> { reorder("RANDOM()") } scope :sort_by_relevance, -> { all } scope :sort_by_flags, -> { order(flags_count: :desc, updated_at: :desc) } - + scope :last_week, -> { where("created_at >= ?", 7.days.ago)} # Ahoy setup visitable # Ahoy will automatically assign visit_id on create diff --git a/app/models/proposal.rb b/app/models/proposal.rb index 22fb55cbd..86d063a36 100644 --- a/app/models/proposal.rb +++ b/app/models/proposal.rb @@ -40,7 +40,8 @@ class Proposal < ActiveRecord::Base scope :sort_by_random, -> { reorder("RANDOM()") } scope :sort_by_relevance , -> { all } scope :sort_by_flags, -> { order(flags_count: :desc, updated_at: :desc) } - + scope :last_week, -> { where("created_at >= ?", 7.days.ago)} + pg_search_scope :pg_search, { against: { title: 'A',