From bdfae2518d164fd305aaf186e4845b4c51e75246 Mon Sep 17 00:00:00 2001 From: Richard Higgins Date: Tue, 25 Aug 2026 16:14:24 -0400 Subject: [PATCH] Brief refactoring in response to Copilot/Claude code review --- lib/um_arclight/traject/ead2_component_config.rb | 7 ------- lib/um_arclight/traject/ead2_config.rb | 13 ++++++++----- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/lib/um_arclight/traject/ead2_component_config.rb b/lib/um_arclight/traject/ead2_component_config.rb index 946d51a..dc459e0 100644 --- a/lib/um_arclight/traject/ead2_component_config.rb +++ b/lib/um_arclight/traject/ead2_component_config.rb @@ -32,13 +32,6 @@ provide "component_identifier_format", "%s_%s" end -each_record do |_record, context| - next unless settings["repository"] - context.clipboard[:repository] = Arclight::Repository.find_by( - slug: settings["repository"] - ).name -end - NAME_ELEMENTS = %w[corpname famname name persname].freeze SEARCHABLE_NOTES_FIELDS = %w[ diff --git a/lib/um_arclight/traject/ead2_config.rb b/lib/um_arclight/traject/ead2_config.rb index 27b2a64..4fb222a 100644 --- a/lib/um_arclight/traject/ead2_config.rb +++ b/lib/um_arclight/traject/ead2_config.rb @@ -68,11 +68,14 @@ end each_record do |_record, context| - next unless settings["repository"] - - context.clipboard[:repository] = Arclight::Repository.find_by( - slug: settings["repository"] - ).name + slug = settings["repository"] + raise "REPOSITORY_ID is not set; cannot index repository fields" if slug.blank? + repository = Arclight::Repository.find_by(slug: slug) + if repository.nil? + raise "No repository found for slug #{slug.inspect} — check REPOSITORY_ID " \ + "against the slugs defined in config/repositories.yml" + end + context.clipboard[:repository] = repository.name end # ==================