mirror of
https://github.com/internetee/registry.git
synced 2025-07-26 04:28:27 +02:00
Merge branch 'story/105664240-whois-updater' into staging
This commit is contained in:
commit
242c6b2f5c
4 changed files with 28 additions and 4 deletions
8
LICENSE
8
LICENSE
|
@ -1,4 +1,4 @@
|
|||
The MIT License (MIT)
|
||||
The MIT/X11 License (MIT/X11)
|
||||
|
||||
Copyright (c) 2014 Estonian Internet Foundation
|
||||
|
||||
|
@ -18,4 +18,8 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name(s) of the above copyright holders
|
||||
shall not be used in advertising or otherwise to promote the sale, use or other
|
||||
dealings in this Software without prior written authorization.
|
||||
|
|
10
app/jobs/regenerate_registrar_whoises_job.rb
Normal file
10
app/jobs/regenerate_registrar_whoises_job.rb
Normal file
|
@ -0,0 +1,10 @@
|
|||
class RegenerateRegistrarWhoisesJob < Que::Job
|
||||
def run(registrar_id)
|
||||
# no return as we want restart job if fails
|
||||
registrar = Registrar.find(registrar_id)
|
||||
|
||||
registrar.whois_records.select(:id).find_in_batches(batch_size: 20) do |group|
|
||||
RegenerateWhoisRecordJob.enqueue group.map(&:id)
|
||||
end
|
||||
end
|
||||
end
|
10
app/jobs/regenerate_whois_record_job.rb
Normal file
10
app/jobs/regenerate_whois_record_job.rb
Normal file
|
@ -0,0 +1,10 @@
|
|||
class RegenerateWhoisRecordJob < Que::Job
|
||||
def run(ids)
|
||||
ids.each do |id|
|
||||
record = WhoisRecord.find_by(id: id)
|
||||
return unless record
|
||||
|
||||
record.save
|
||||
end
|
||||
end
|
||||
end
|
|
@ -51,10 +51,10 @@ class Registrar < ActiveRecord::Base
|
|||
|
||||
WHOIS_TRIGGERS = %w(name email phone street city state zip)
|
||||
|
||||
after_save :update_whois_records
|
||||
after_commit :update_whois_records
|
||||
def update_whois_records
|
||||
return true unless changed? && (changes.keys & WHOIS_TRIGGERS).present?
|
||||
whois_records.map(&:save) # slow currently
|
||||
RegenerateRegistrarWhoisesJob.enqueue id
|
||||
end
|
||||
|
||||
after_create :create_cash_account
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue