mirror of
https://github.com/internetee/registry.git
synced 2025-05-18 02:09:39 +02:00
Update all contact code to upcase
This commit is contained in:
parent
4ea983c865
commit
c704f4894a
5 changed files with 18 additions and 3 deletions
|
@ -59,7 +59,7 @@ class Epp::ContactsController < EppController
|
|||
end
|
||||
|
||||
def find_contact
|
||||
code = params[:parsed_frame].css('id').text.strip
|
||||
code = params[:parsed_frame].css('id').text.strip.upcase
|
||||
@contact = Epp::Contact.find_by(code: code)
|
||||
|
||||
if @contact.blank?
|
||||
|
|
|
@ -112,7 +112,7 @@ class Contact < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def generate_code
|
||||
self.code = SecureRandom.hex(4) if code.blank? || code_overwrite_allowed
|
||||
self.code = SecureRandom.hex(4).upcase if code.blank? || code_overwrite_allowed
|
||||
end
|
||||
|
||||
def generate_auth_info
|
||||
|
|
|
@ -59,6 +59,7 @@ class Epp::Contact < Contact
|
|||
prefix = custom_code.split(':').first
|
||||
custom_code = "#{registrar.code}:#{custom_code}" if prefix != registrar.code
|
||||
custom_code = nil if custom_code == registrar.code
|
||||
custom_code.upcase! if custom_code.present?
|
||||
end
|
||||
|
||||
super(
|
||||
|
|
14
db/migrate/20150505111437_upcase_all_contact_codes.rb
Normal file
14
db/migrate/20150505111437_upcase_all_contact_codes.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
class UpcaseAllContactCodes < ActiveRecord::Migration
|
||||
def change
|
||||
puts 'Update contact code to upcase...'
|
||||
@i = 0
|
||||
puts @i
|
||||
Contact.find_in_batches(batch_size: 10000) do |batch|
|
||||
batch.each do |c|
|
||||
c.update_column(:code, c.code.upcase)
|
||||
end
|
||||
GC.start
|
||||
puts @i += 10000
|
||||
end
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20150504110926) do
|
||||
ActiveRecord::Schema.define(version: 20150505111437) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue