FEATURE: add `before` topic list filter

This commit is contained in:
Sam 2017-03-02 14:54:26 -05:00
parent 872d9eae45
commit 4dac4c69a6
2 changed files with 10 additions and 1 deletions

View File

@ -7,7 +7,8 @@ export const queryParams = {
search: { replace: true, refreshModel: true },
max_posts: { replace: true, refreshModel: true },
q: { replace: true, refreshModel: true },
tags: { replace: true }
tags: { replace: true },
before: { replace: true, refreshModel: true}
};
// Basic controller options

View File

@ -13,6 +13,7 @@ class TopicQuery
def self.public_valid_options
@public_valid_options ||=
%i(page
before
topic_ids
exclude_category_ids
category
@ -592,6 +593,13 @@ class TopicQuery
end
require_deleted_clause = true
if before = options[:before]
if (before = before.to_i) > 0
result = result.where('topics.created_at < ?', before.to_i.days.ago)
end
end
if status = options[:status]
case status
when 'open'