mirror of
https://github.com/discourse/discourse.git
synced 2025-02-17 18:02:45 +08:00
handle posts:rebake_match task without type argument
This commit is contained in:
parent
054ee4dc55
commit
dc4799dda2
|
@ -30,14 +30,15 @@ desc 'Rebake all posts matching string/regex'
|
||||||
task 'posts:rebake_match', [:pattern, :type] => [:environment] do |_,args|
|
task 'posts:rebake_match', [:pattern, :type] => [:environment] do |_,args|
|
||||||
pattern = args[:pattern]
|
pattern = args[:pattern]
|
||||||
type = args[:type]
|
type = args[:type]
|
||||||
|
type = type.downcase if type
|
||||||
if !pattern
|
if !pattern
|
||||||
puts "ERROR: Expecting rake posts:rebake_match[pattern,type]"
|
puts "ERROR: Expecting rake posts:rebake_match[pattern,type]"
|
||||||
exit 1
|
exit 1
|
||||||
end
|
end
|
||||||
|
|
||||||
if type.downcase == "regex"
|
if type == "regex"
|
||||||
search = Post.where("raw ~ ?", pattern)
|
search = Post.where("raw ~ ?", pattern)
|
||||||
elsif type.downcase == "string" || !type
|
elsif type == "string" || !type
|
||||||
search = Post.where("raw ILIKE ?", "%#{pattern}%")
|
search = Post.where("raw ILIKE ?", "%#{pattern}%")
|
||||||
else
|
else
|
||||||
puts "ERROR: Expecting rake posts:rebake_match[pattern,type] where type is string or regex"
|
puts "ERROR: Expecting rake posts:rebake_match[pattern,type] where type is string or regex"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user