mirror of
https://github.com/internetee/registry.git
synced 2025-07-25 20:18:22 +02:00
WIP with contact import
This commit is contained in:
parent
3149d0731d
commit
a598b46723
4 changed files with 63 additions and 3 deletions
5
app/models/legacy/contact.rb
Normal file
5
app/models/legacy/contact.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
module Legacy
|
||||||
|
class Contact < Db
|
||||||
|
self.table_name = :contact
|
||||||
|
end
|
||||||
|
end
|
6
app/models/legacy/object_registry.rb
Normal file
6
app/models/legacy/object_registry.rb
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
module Legacy
|
||||||
|
class ObjectRegistry < Db
|
||||||
|
self.table_name = :object_registry
|
||||||
|
self.inheritance_column = nil
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddLegacyColumnsForContact < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :contacts, :legacy_id, :integer
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,9 +1,9 @@
|
||||||
namespace :import do
|
namespace :import do
|
||||||
desc "Imports registrars"
|
desc 'Imports registrars'
|
||||||
task registrars: :environment do
|
task registrars: :environment do
|
||||||
puts '-----> Importing registrars...'
|
puts '-----> Importing registrars...'
|
||||||
|
|
||||||
# Registrar.where('legacy_id IS NOT NULL').delete_all
|
Registrar.where('legacy_id IS NOT NULL').delete_all
|
||||||
|
|
||||||
registrars = []
|
registrars = []
|
||||||
existing_ids = Registrar.pluck(:legacy_id)
|
existing_ids = Registrar.pluck(:legacy_id)
|
||||||
|
@ -27,7 +27,9 @@ namespace :import do
|
||||||
url: x.url.try(:strip),
|
url: x.url.try(:strip),
|
||||||
directo_handle: x.directo_handle.try(:strip),
|
directo_handle: x.directo_handle.try(:strip),
|
||||||
vat: x.vat,
|
vat: x.vat,
|
||||||
legacy_id: x.id
|
legacy_id: x.id,
|
||||||
|
creator_str: "rake-#{`whoami`.strip} #{ARGV.join ' '}",
|
||||||
|
updator_str: "rake-#{`whoami`.strip} #{ARGV.join ' '}"
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -35,4 +37,46 @@ namespace :import do
|
||||||
|
|
||||||
puts '-----> Registrars imported'
|
puts '-----> Registrars imported'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# desc 'Import contacts'
|
||||||
|
# task contact: :environment do
|
||||||
|
# puts '-----> Importing contacts...'
|
||||||
|
|
||||||
|
# contacts = []
|
||||||
|
# existing_ids = Contact.pluck(:legacy_id)
|
||||||
|
|
||||||
|
# Legacy::Contact.all.each do |x|
|
||||||
|
# next if existing_ids.include?(x.id)
|
||||||
|
|
||||||
|
# 1;"RC";"born number"
|
||||||
|
# 2;"OP";"identity card number" -> priv
|
||||||
|
# 3;"PASS";"passwport" ->
|
||||||
|
# 4;"ICO";"organization identification number"
|
||||||
|
# 5;"MPSV";"social system identification"
|
||||||
|
# 6;"BIRTHDAY";"day of birth"
|
||||||
|
|
||||||
|
# contacts << Contact.new({
|
||||||
|
# code: ,
|
||||||
|
# #type: , # not needed
|
||||||
|
# #reg_no: x.ssn.try(:strip),
|
||||||
|
# phone: x.telephone.try(:strip),
|
||||||
|
# email: x.email.try(:strip),
|
||||||
|
# fax: x.fax.try(:strip),
|
||||||
|
# ident: x.ssn.try(:strip),
|
||||||
|
# ident_type: ,
|
||||||
|
# #created_by_id: , # not needed
|
||||||
|
# #updated_by_id: , # not needed
|
||||||
|
# auth_info: ,
|
||||||
|
# name: x.name.try(:strip),
|
||||||
|
# org_name: x.organization.try(:strip),
|
||||||
|
# registrar_id: ,
|
||||||
|
# creator_str: "rake-#{`whoami`.strip} #{ARGV.join ' '}",
|
||||||
|
# updator_str: "rake-#{`whoami`.strip} #{ARGV.join ' '}"
|
||||||
|
# ident_country_code: x.country.try(:strip),
|
||||||
|
# legacy_id: x.id
|
||||||
|
# })
|
||||||
|
# end
|
||||||
|
|
||||||
|
# puts '-----> Contacts imported'
|
||||||
|
# end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue