handle posts:rebake_match task without type argument

This commit is contained in:
Arpit Jalan 2016-08-17 01:01:06 +05:30
parent 054ee4dc55
commit dc4799dda2
1 changed files with 3 additions and 2 deletions

View File

@ -30,14 +30,15 @@ desc 'Rebake all posts matching string/regex'
task 'posts:rebake_match', [:pattern, :type] => [:environment] do |_,args|
pattern = args[:pattern]
type = args[:type]
type = type.downcase if type
if !pattern
puts "ERROR: Expecting rake posts:rebake_match[pattern,type]"
exit 1
end
if type.downcase == "regex"
if type == "regex"
search = Post.where("raw ~ ?", pattern)
elsif type.downcase == "string" || !type
elsif type == "string" || !type
search = Post.where("raw ILIKE ?", "%#{pattern}%")
else
puts "ERROR: Expecting rake posts:rebake_match[pattern,type] where type is string or regex"