Submit social housing lettings and sales data (CORE)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

22 lines
525 B

require "csv"
module Imports
class LocalAuthorityLinksService
attr_reader :path, :count
def initialize(path:)
@path = path
@count = 0
end
def call
CSV.foreach(path, headers: true) do |row|
LocalAuthorityLink.upsert(
{ local_authority_id: LocalAuthority.find_by(code: row["local_authority_code"]).id,
linked_local_authority_id: LocalAuthority.find_by(code: row["linked_local_authority_code"]).id },
)
@count += 1
end
end
end
end