FEATURE: add `before` topic list filter
This commit is contained in:
parent
872d9eae45
commit
4dac4c69a6
|
@ -7,7 +7,8 @@ export const queryParams = {
|
||||||
search: { replace: true, refreshModel: true },
|
search: { replace: true, refreshModel: true },
|
||||||
max_posts: { replace: true, refreshModel: true },
|
max_posts: { replace: true, refreshModel: true },
|
||||||
q: { replace: true, refreshModel: true },
|
q: { replace: true, refreshModel: true },
|
||||||
tags: { replace: true }
|
tags: { replace: true },
|
||||||
|
before: { replace: true, refreshModel: true}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Basic controller options
|
// Basic controller options
|
||||||
|
|
|
@ -13,6 +13,7 @@ class TopicQuery
|
||||||
def self.public_valid_options
|
def self.public_valid_options
|
||||||
@public_valid_options ||=
|
@public_valid_options ||=
|
||||||
%i(page
|
%i(page
|
||||||
|
before
|
||||||
topic_ids
|
topic_ids
|
||||||
exclude_category_ids
|
exclude_category_ids
|
||||||
category
|
category
|
||||||
|
@ -592,6 +593,13 @@ class TopicQuery
|
||||||
end
|
end
|
||||||
|
|
||||||
require_deleted_clause = true
|
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]
|
if status = options[:status]
|
||||||
case status
|
case status
|
||||||
when 'open'
|
when 'open'
|
||||||
|
|
Loading…
Reference in New Issue