mirror of
https://github.com/internetee/registry.git
synced 2025-07-29 22:16:19 +02:00
21 lines
453 B
Ruby
21 lines
453 B
Ruby
class ScanCsvRegistryBusinnesContactsJob < ApplicationJob
|
|
def perform(filename)
|
|
BusinessRegistryContact.delete_all
|
|
|
|
return unless File.exist?(filename)
|
|
|
|
enumurate_csv_file(filename)
|
|
end
|
|
|
|
private
|
|
|
|
def enumurate_csv_file(filename)
|
|
CSV.foreach(filename, headers: true, col_sep: ';') do |row|
|
|
BusinessRegistryContact.create(
|
|
name: row[0],
|
|
registry_code: row[1],
|
|
status: row[5]
|
|
)
|
|
end
|
|
end
|
|
end
|