posts index: clean up limit:<n> / order:random parsing (#2894)
* Move the limit:<n> / order:random metatag parsing from the controller to the post set. * Introduce `Tag.has_metatag?` and use it to parse these metatags instead of using a regex (#2894).
This commit is contained in:
@@ -445,6 +445,13 @@ class Tag < ApplicationRecord
|
||||
tag.include?("*")
|
||||
end
|
||||
|
||||
def has_metatag?(tags, *metatags)
|
||||
return nil if tags.blank?
|
||||
|
||||
tags = scan_query(tags.to_str) if tags.respond_to?(:to_str)
|
||||
tags.grep(/\A#{Regexp.union(metatags.map(&:to_s))}:(.+)\z/i) { $1 }.first
|
||||
end
|
||||
|
||||
def parse_query(query, options = {})
|
||||
q = {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user