mirror of
https://github.com/internetee/registry.git
synced 2025-08-05 01:11:43 +02:00
implement scan valid org contacts
This commit is contained in:
parent
7c8c9120b5
commit
8837252a46
4 changed files with 56 additions and 73 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue