1
0
Fork 0

Improve code

This commit is contained in:
Alex Kotov 2019-10-01 04:12:04 +05:00
parent 30e4939ce6
commit 39acdd74c9
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
1 changed files with 10 additions and 3 deletions

View File

@ -45,8 +45,9 @@ CSV.foreach(
org_unit_kinds_filename,
col_sep: '|',
) do |(codename, parent, short_name, name)|
parent = parent.blank? ? nil : OrgUnitKind.find_by!(codename: parent.strip)
codename.strip!
parent = parent.strip.presence
short_name.strip!
name.strip!
@ -56,7 +57,7 @@ CSV.foreach(
codename: codename,
short_name: short_name,
name: name,
parent_kind: parent.nil? ? nil : OrgUnitKind.find_by!(codename: parent),
parent_kind: parent,
)
end
@ -64,7 +65,13 @@ CSV.foreach(
relation_statuses_filename,
col_sep: '|',
) do |(org_unit_kind, codename, name)|
org_unit_kind = OrgUnitKind.find_by! codename: org_unit_kind.strip
org_unit_kind =
if org_unit_kind.blank?
nil
else
OrgUnitKind.find_by!(codename: org_unit_kind.strip)
end
codename.strip!
name.strip!