FEATURE: optionally delay the rebake_match task
This commit is contained in:
parent
c1c3237d58
commit
13aff1f2f8
|
@ -26,13 +26,17 @@ task 'posts:fix_letter_avatars' => :environment do
|
||||||
puts "", "#{rebaked} posts done!", ""
|
puts "", "#{rebaked} posts done!", ""
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'Rebake all posts matching string/regex'
|
desc 'Rebake all posts matching string/regex and optionally delay the loop'
|
||||||
task 'posts:rebake_match', [:pattern, :type] => [:environment] do |_,args|
|
task 'posts:rebake_match', [:pattern, :type, :delay] => [:environment] do |_,args|
|
||||||
pattern = args[:pattern]
|
pattern = args[:pattern]
|
||||||
type = args[:type]
|
type = args[:type]
|
||||||
type = type.downcase if type
|
type = type.downcase if type
|
||||||
|
delay = args[:delay].to_i if args[:delay]
|
||||||
if !pattern
|
if !pattern
|
||||||
puts "ERROR: Expecting rake posts:rebake_match[pattern,type]"
|
puts "ERROR: Expecting rake posts:rebake_match[pattern,type,delay]"
|
||||||
|
exit 1
|
||||||
|
elsif delay && delay < 1
|
||||||
|
puts "ERROR: delay parameter should be an integer and greater than 0"
|
||||||
exit 1
|
exit 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -51,6 +55,7 @@ task 'posts:rebake_match', [:pattern, :type] => [:environment] do |_,args|
|
||||||
search.find_each do |post|
|
search.find_each do |post|
|
||||||
rebake_post(post)
|
rebake_post(post)
|
||||||
print_status(rebaked += 1, total)
|
print_status(rebaked += 1, total)
|
||||||
|
sleep(delay) if delay
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "", "#{rebaked} posts done!", ""
|
puts "", "#{rebaked} posts done!", ""
|
||||||
|
|
Loading…
Reference in New Issue