Skip to content

Commit

Permalink
specified logging if an admin set name couldnt be found
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcam-src committed Aug 30, 2024
1 parent c9a93fc commit bd1921e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions app/helpers/work_utils_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ def self.fetch_work_data_by_fileset_id(fileset_id)
admin_set_name = work['admin_set_tesim']&.first
# If the admin set name is not nil, fetch the admin set
# Set the admin set to an empty hash if the solr query returns nil
admin_set = admin_set_name ? ActiveFedora::SolrService.get("title_tesim:#{admin_set_name}", { rows: 1, 'df' => 'title_tesim'})['response']['docs'].first || {} : {}
Rails.logger.warn("No admin set found for title_tesim: #{admin_set_name}") if admin_set.blank?
admin_set = admin_set_name ? ActiveFedora::SolrService.get("title_tesim:#{admin_set_name}", { :rows => 1, 'df' => 'title_tesim'})['response']['docs'].first || {} : {}
warning_message = admin_set_name ? "No admin set found for title_tesim: #{admin_set_name}" : "No admin set found with fileset id: #{fileset_id}"
Rails.logger.warn(warning_message) if admin_set.blank?

{
work_id: work['id'] || 'Unknown',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
let(:service) { described_class.new }

before do
allow(ActiveFedora::SolrService).to receive(:get).with("title_tesim:#{admin_set_title}", { rows: 1, 'df' => 'title_tesim'}).and_return('response' => { 'docs' => [mock_admin_set] })
allow(ActiveFedora::SolrService).to receive(:get).with("title_tesim:#{admin_set_title}", { :rows => 1, 'df' => 'title_tesim'}).and_return('response' => { 'docs' => [mock_admin_set] })
end

after do
Expand Down

0 comments on commit bd1921e

Please sign in to comment.