Skip to content

Commit

Permalink
added whitelist filter
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegPhenomenon committed Sep 10, 2024
1 parent 4aafe29 commit 2246bbf
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 17 deletions.
45 changes: 28 additions & 17 deletions app/jobs/company_register_status_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CompanyRegisterStatusJob < ApplicationJob

def perform(days_interval = 14, spam_time_delay = 1, batch_size = 100)
sampling_registrant_contact(days_interval).find_in_batches(batch_size: batch_size) do |contacts|
contacts.each { |contact| proceed_company_status(contact, spam_time_delay) }
contacts.reject { |contact| whitelisted_company?(contact) }.each { |contact| proceed_company_status(contact, spam_time_delay) }
end
end

Expand Down Expand Up @@ -83,27 +83,30 @@ def check_for_force_delete(contact)
end

def lift_force_delete(contact)
contact.domains.each do |domain|
domain.lift_force_delete
end
contact.domains.each(&:lift_force_delete)
end

def delete_process(contact)
company_details_response = contact.return_company_details

if company_details_response.empty?
schedule_force_delete(contact)

return
end

kandeliik_tekstina = company_details_response.first.kandeliik.last.last.kandeliik_tekstina

if kandeliik_tekstina == PAYMENT_STATEMENT_BUSINESS_REGISTRY_REASON
soft_delete_company(contact)
else
schedule_force_delete(contact)
end
if company_details_response.empty?
schedule_force_delete(contact)
return
end

kandeliik_tekstina = extract_kandeliik_tekstina(company_details_response)

if kandeliik_tekstina == PAYMENT_STATEMENT_BUSINESS_REGISTRY_REASON
soft_delete_company(contact)
else
schedule_force_delete(contact)
end
end

private

def extract_kandeliik_tekstina(company_details_response)
company_details_response.first.kandeliik.last.last.kandeliik_tekstina
end

def soft_delete_company(contact)
Expand All @@ -113,4 +116,12 @@ def soft_delete_company(contact)

puts "Soft delete process initiated for company: #{contact.name} with ID: #{contact.id}"
end

def whitelisted_companies
@whitelisted_companies ||= ENV['whitelist_companies'].split(',')
end

def whitelisted_company?(contact)
whitelisted_companies.include?(contact.ident)
end
end
4 changes: 4 additions & 0 deletions config/application.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -252,3 +252,7 @@ billing_system_integrated: 'true'
secret_access_word: 'please-Give-Me-accesS'
secret_word: 'this-secret-should-be-change'
allow_accr_endspoints: 'true'

whitelist_companies:
- '12345678'
- '87654321'

0 comments on commit 2246bbf

Please sign in to comment.