From abc4dff0fea5556acfeb17358dfb59166924ac76 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 2 Mar 2017 15:11:38 -0500 Subject: [PATCH] FEATURE: add bumped_before query param for topic list --- .../discourse/controllers/discovery-sortable.js.es6 | 3 ++- lib/topic_query.rb | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/controllers/discovery-sortable.js.es6 b/app/assets/javascripts/discourse/controllers/discovery-sortable.js.es6 index 077a53c6bba..df055c0868b 100644 --- a/app/assets/javascripts/discourse/controllers/discovery-sortable.js.es6 +++ b/app/assets/javascripts/discourse/controllers/discovery-sortable.js.es6 @@ -8,7 +8,8 @@ export const queryParams = { max_posts: { replace: true, refreshModel: true }, q: { replace: true, refreshModel: true }, tags: { replace: true }, - before: { replace: true, refreshModel: true} + before: { replace: true, refreshModel: true}, + bumped_before: { replace: true, refreshModel: true} }; // Basic controller options diff --git a/lib/topic_query.rb b/lib/topic_query.rb index 841c0393f83..4eb4999ab06 100644 --- a/lib/topic_query.rb +++ b/lib/topic_query.rb @@ -14,6 +14,7 @@ class TopicQuery @public_valid_options ||= %i(page before + bumped_before topic_ids exclude_category_ids category @@ -600,6 +601,12 @@ class TopicQuery end end + if bumped_before = options[:bumped_before] + if (bumped_before = bumped_before.to_i) > 0 + result = result.where('topics.bumped_at < ?', bumped_before.to_i.days.ago) + end + end + if status = options[:status] case status when 'open'