Skip to content

Commit

Permalink
change unique collection from by ident to code
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegPhenomenon committed Nov 8, 2024
1 parent 7da6eea commit 3cf4e29
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/jobs/company_register_status_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def check_for_force_delete(contact)
end

def lift_force_delete(contact)
contact.registrant_domains.each(&:lift_force_delete)
contact.registrant_domains.each(&:cancel_force_delete)
end

def delete_process(contact)
Expand Down
19 changes: 10 additions & 9 deletions lib/tasks/company_status.rake
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,17 @@ namespace :company_status do
contacts_query = contacts_query.joins(:registrant_domains).distinct
end

unique_contacts = contacts_query.to_a.uniq(&:ident)
unique_contacts = contacts_query.to_a.uniq(&:code)

unique_contacts.each do |contact|
next if whitelisted_companies.include?(contact.ident)

if company_data.key?(contact.ident)
update_company_status(contact: contact, status: company_data[contact.ident][COMPANY_STATUS])
puts "Company: #{contact.name} with ident: #{contact.ident} and ID: #{contact.id} has status: #{company_data[contact.ident][COMPANY_STATUS]}"
else
update_company_status(contact: contact, status: 'K')
status = company_data.fetch(contact.ident, {}).fetch(COMPANY_STATUS, 'K')
update_company_status(contact: contact, status: status)
puts "Company: #{contact.name} with ident: #{contact.ident} and ID: #{contact.id} has status: #{status}"

puts "Contact domain: #{contact.registrant_domains.pluck(:name)}"
if status == 'K'
sort_companies_to_files(
contact: contact,
missing_companies_in_business_registry_path: missing_companies_in_business_registry_path,
Expand Down Expand Up @@ -155,7 +156,7 @@ namespace :company_status do
end

def put_company_to_missing_file(contact:, path:)
write_to_csv_file(csv_file_path: path, headers: ["ID", "Ident", "Name", "Contact Type"], attrs: [contact.id, contact.ident, contact.name, determine_contact_type(contact)])
write_to_csv_file(csv_file_path: path, headers: ["ID", "Code", "Ident", "Name", "Contact Type"], attrs: [contact.id, contact.code, contact.ident, contact.name, determine_contact_type(contact)])
end

def sort_companies_to_files(contact:, missing_companies_in_business_registry_path:, deleted_companies_from_business_registry_path:, soft_delete_enable:, sleep_time:)
Expand All @@ -176,8 +177,8 @@ namespace :company_status do

if status == DELETED_FROM_REGISTRY_STATUS
csv_file_path = deleted_companies_from_business_registry_path
headers = ["ID", "Ident", "Name", "Status", "Kandeliik Type", "Kandeliik Tekstina", "kande_kpv", "Contact Type"]
attrs = [contact.id, contact.ident, contact.name, status, kandeliik_type, kandeliik_tekstina, kande_kpv, determine_contact_type(contact)]
headers = ["ID", "Code", "Ident", "Name", "Status", "Kandeliik Type", "Kandeliik Tekstina", "kande_kpv", "Contact Type"]
attrs = [contact.id, contact.code, contact.ident, contact.name, status, kandeliik_type, kandeliik_tekstina, kande_kpv, determine_contact_type(contact)]
write_to_csv_file(csv_file_path: csv_file_path, headers: headers, attrs: attrs)

puts "Company: #{contact.name} with ident: #{contact.ident} and ID: #{contact.id} has status #{status}, company id: #{contact.id}"
Expand Down

0 comments on commit 3cf4e29

Please sign in to comment.