This commit is contained in:
Stas 2016-04-06 14:22:43 +03:00
commit bf9bb8b5f1
319 changed files with 3947 additions and 426329 deletions

View file

@ -1,18 +0,0 @@
Rake::Task["assets:precompile"].enhance do
Rake::Task["assets:non_digested"].invoke
end
namespace :assets do
task non_digested: :environment do
manifest_path = Dir.glob(File.join(Rails.root, 'public/assets/.sprockets-manifest-*.json')).first
manifest_data = JSON.load(File.new(manifest_path))
manifest_data["assets"].each do |logical_path, digested_path|
FileUtils.cp("public/assets/#{digested_path}", "public/assets/#{logical_path}")
end
end
end
task as: :environment do
system('RAILS_ENV=production rake assets:precompile')
end

View file

@ -32,5 +32,44 @@ namespace :convert do
d.save!
end
end
desc 'Contact Address Country Code Upcase'
task country_code_upcase: :environment do
count = 0
Contact.find_each do |c|
if c.country_code.present? && c.country_code != c.country_code.upcase
c.country_code = c.country_code.upcase
c.update_columns(country_code: c.country_code.upcase)
count +=1
puts "#{count} contacts has been changed" if count % 1000 == 0
end
end
puts "Contacts change has been finished. Starting ContactVersions"
count = 0
ContactVersion.find_each do |c|
if (if_object = (c.object && c.object["country_code"].present? && c.object["country_code"] != c.object["country_code"].upcase)) ||
(if_changes = (c.object_changes && c.object_changes["country_code"].present? && c.object_changes["country_code"] != c.object_changes["country_code"].map{|e|e.try(:upcase)}))
if if_object
h = c.object
h["country_code"] = h["country_code"].try(:upcase)
c.object = h
end
if if_changes
h = c.object_changes
h["country_code"] = h["country_code"].map{|e|e.try(:upcase)}
c.object_changes = h
end
c.update_columns(object: c.object, object_changes: c.object_changes)
count +=1
puts "#{count} contact histories has been changed" if count % 1000 == 0
end
end
end
end

19
lib/tasks/epp.rake Normal file
View file

@ -0,0 +1,19 @@
namespace :epp do
desc 'EPP actions'
task all: :environment do
Rake::Task['epp:trim_documents'].invoke
end
desc 'Trim logs'
task trim_documents: :environment do
puts '-----> Running query'
sql = <<-SQL
UPDATE epp_logs SET request = regexp_replace(request, '<eis:legalDocument(.|\n)*?<\/eis:legalDocument>', '<eis:legalDocument>[FILTERED]<\eis:legalDocument>');
SQL
ApiLog::EppLog.connection.execute(sql)
puts "-----> Query done"
end
end

View file

@ -3,15 +3,24 @@ namespace :whois do
task regenerate: :environment do
start = Time.zone.now.to_f
@i = 0
print "-----> Regenerate Registry whois_records table and sync with whois server..."
ActiveRecord::Base.uncached do
puts "\n#{@i}"
Domain.included.find_in_batches(batch_size: 10000) do |batch|
batch.map(&:update_whois_record)
puts(@i += 10000)
GC.start
print "\n-----> Update domains whois_records"
Domain.find_in_batches.each do |group|
UpdateWhoisRecordJob.enqueue group.map(&:name), 'domain'
end
print "\n-----> Update blocked domains whois_records"
BlockedDomain.find_in_batches.each do |group|
UpdateWhoisRecordJob.enqueue group.map(&:name), 'blocked'
end
print "\n-----> Update reserved domains whois_records"
ReservedDomain.find_in_batches.each do |group|
UpdateWhoisRecordJob.enqueue group.map(&:name), 'reserved'
end
end
puts "\n-----> all done in #{(Time.zone.now.to_f - start).round(2)} seconds"
end

View file

@ -23,7 +23,7 @@ namespace :zonefile do
exclude_filter := '%.%.' || i_origin;
END IF;
SELECT ROUND(extract(epoch from now() at time zone 'utc')) INTO serial_num;
SELECT (extract(epoch from now() at time zone 'utc'))::int INTO serial_num;
-- zonefile header
SELECT concat(