1
0
Fork 0
This repository has been archived on 2023-03-27. You can view files and clone it, but cannot push or open issues or pull requests.
lpr-partynest/app/interactors/import_all.rb

36 lines
767 B
Ruby
Raw Normal View History

2019-08-18 00:44:29 -04:00
# frozen_string_literal: true
class ImportAll
include Interactor
def dirname
@dirname ||= Pathname.new(context.dirname).realpath.freeze
end
def call
2019-08-18 00:58:11 -04:00
import 'LPR_REGIONAL_DEPTS_ALL.csv', ImportRegionalOffice
import 'LPR_PEOPLE_ALL.csv', ImportPerson
import 'LPR_CONTACTS_ALL.csv', ImportContact
import 'LPR_PARTY_MEMBERS_ALL.csv', ImportRelationship
2019-08-18 00:47:02 -04:00
# Imported in "db/seeds.rb":
#
# LPR_CONTACT_NETWORKS_ALL.csv
# LPR_REGIONS_ALL.csv
# Unnecessary:
#
# LPR_EVENTS_ALL.csv
# LPR_STATUSES_ALL.csv
# LPR_USERS.csv
2019-08-18 00:44:29 -04:00
end
private
def import(filename, interactor)
CSV.read(dirname.join(filename), col_sep: ';').drop(1).each do |row|
interactor.call row: row
end
end
end