implement scan valid org contacts

This commit is contained in:
Oleg Hasjanov 2021-06-17 14:38:49 +03:00
parent 7c8c9120b5
commit 8837252a46
4 changed files with 56 additions and 73 deletions

View file

@ -2,7 +2,7 @@ class ScanCsvRegistryBusinnesContactsJob < ApplicationJob
def perform(filename)
BusinessRegistryContact.delete_all
return p 'File not exist!' unless File.exist?(filename)
return unless File.exist?(filename)
enumurate_csv_file(filename)
end
@ -10,17 +10,12 @@ class ScanCsvRegistryBusinnesContactsJob < ApplicationJob
private
def enumurate_csv_file(filename)
i = 0
CSV.foreach(filename, headers: true, col_sep: ';') do |row|
record = BusinessRegistryContact.create(
BusinessRegistryContact.create(
name: row[0],
registry_code: row[1],
status: row[5]
)
i += 1
p "#{record} is successfully created - #{i} count"
end
end
end