Skip to content

Commit 22afd45

Browse files
committed
add allowlist of presses to TMM CSV task
1 parent 3988270 commit 22afd45

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/tasks/tmm/tmm_csv_monograph_create_update.rake

+8-2
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,15 @@ namespace :heliotrope do
5555
# `blank_metadata` is used to enable deletion of existing values. It's *ESSENTIAL* that this hash only contain...
5656
# fields actually present in the TMM CSV (those known to TMM as mentioned above). Hence the `select`.
5757
tmm_csv_header_field_names = rows[0].to_h.keys.map { |k| k&.strip }
58-
blank_metadata = monograph_fields.select{ |field| tmm_csv_header_field_names.include?(field[:field_name]) }
58+
blank_metadata = monograph_fields.select { |field| tmm_csv_header_field_names.include?(field[:field_name]) }
5959
.pluck(:metadata_name).map { |name| [name, nil] }.to_h
6060

61+
# michigan and its sub-presses are always allowed
62+
allowed_presses = Press.where(parent: Press.where(subdomain: 'michigan').first).map(&:subdomain).push('michigan')
63+
# gradually we'll be adding more allowed (non-EBC) presses to the list here
64+
allowed_presses += ['bigten', 'livedplaces']
65+
allowed_presses.uniq! # just in case
66+
6167
rows.each do |row|
6268
row_num += 1
6369

@@ -84,7 +90,7 @@ namespace :heliotrope do
8490

8591
press = tmm_press_name_map[press] if tmm_press_name_map[press].present?
8692

87-
unless Press.exists?(subdomain: press)
93+
unless allowed_presses.include?(press) && Press.exists?(subdomain: press)
8894
puts "Invalid Press value '#{press}' on row #{row_num} ... SKIPPING ROW"
8995
next
9096
end

0 commit comments

Comments
 (0)