111297422-que_jobs

This commit is contained in:
Stas 2016-01-25 16:56:04 +02:00
parent 764abdfd89
commit 8ed8a46046
3 changed files with 15 additions and 1 deletions

View file

@ -0,0 +1,10 @@
class UpdateWhoisRecordJob < Que::Job
def run(ids, type)
ids.each do |id|
record = WhoisRecord.find_by(id: id)
return unless record
record.save
end
end
end

View file

@ -106,7 +106,7 @@ class WhoisRecord < ActiveRecord::Base
self.json = generated_json
self.body = generated_body
self.name = json['name']
self.registrar_id = domain.registrar_id # for faster registrar updates
self.registrar_id = domain.registrar_id if domain # for faster registrar updates
end
def update_whois_server

View file

@ -12,6 +12,10 @@ namespace :whois do
puts(@i += 10000)
GC.start
end
GC.start
UpdateWhoisRecordJob.enqueue WhoisRecord.find_each.map(&:id), 'domain'
end
puts "\n-----> all done in #{(Time.zone.now.to_f - start).round(2)} seconds"
end