diff --git a/app/components/work_show_info_component.rb b/app/components/work_show_info_component.rb index 84ec0e7d0..badd7af0d 100644 --- a/app/components/work_show_info_component.rb +++ b/app/components/work_show_info_component.rb @@ -172,7 +172,7 @@ def oral_history_interviewer_profiles end def oral_history_number - @oral_history_number ||= work.external_id.find { |id| id.category == "interview"}&.value + @oral_history_number ||= work.oral_history_number end private diff --git a/app/controllers/admin/works_controller.rb b/app/controllers/admin/works_controller.rb index 2326172e9..7fd62bd27 100644 --- a/app/controllers/admin/works_controller.rb +++ b/app/controllers/admin/works_controller.rb @@ -273,7 +273,7 @@ def remove_searchable_transcript_source # GET /admin/works/ab2323ac/download_searchable_transcript_source def download_searchable_transcript_source authorize! :read, @work - id = @work.external_id.find { |id| id.category == "interview" }&.value + id = @work.oral_history_number id ||= @work.friendlier_id filename = "#{id}_transcript.txt" send_data @work.oral_history_content!.searchable_transcript_source, diff --git a/app/models/oral_history_request.rb b/app/models/oral_history_request.rb index 1e59eaddb..451afc173 100644 --- a/app/models/oral_history_request.rb +++ b/app/models/oral_history_request.rb @@ -25,18 +25,12 @@ class OralHistoryRequest < ApplicationRecord end def oral_history_number - return nil if self.work.external_id.nil? - oh_id = self.work.external_id.find {|id| id.attributes["category"] == "interview"} - return nil if oh_id.nil? - oh_id.attributes['value'] + self.work.oral_history_number end - # delegate to oral_history_requester, or while we're migrating default to # local attributes def requester_email oral_history_requester&.email end - - end diff --git a/app/models/work.rb b/app/models/work.rb index ead4f8921..3ee74a2fa 100644 --- a/app/models/work.rb +++ b/app/models/work.rb @@ -132,6 +132,11 @@ def has_text_extraction? ocr_requested? || pdf_text_extraction? end + # Does not cache, looks up everytime, first external_id with category "interview", if present + def oral_history_number + self.external_id&.find { |id| id.category == "interview" }&.value + end + # With one pg recursive CTE find _all_ descendent members, through # multiple levels. # diff --git a/app/presenters/citable_attributes.rb b/app/presenters/citable_attributes.rb index 1f964f592..7460986b2 100644 --- a/app/presenters/citable_attributes.rb +++ b/app/presenters/citable_attributes.rb @@ -581,9 +581,7 @@ def archive_location end def interview_id - interview_ids = CitableAttributes::work_lookup(work, "external_id", "interview") - return nil if interview_ids.blank? - interview_ids.first + work.oral_history_number end end diff --git a/lib/tasks/data_fixes/add_transcripts_to_oral_histories.rake b/lib/tasks/data_fixes/add_transcripts_to_oral_histories.rake index 4d74d726c..0ed37f412 100644 --- a/lib/tasks/data_fixes/add_transcripts_to_oral_histories.rake +++ b/lib/tasks/data_fixes/add_transcripts_to_oral_histories.rake @@ -33,7 +33,7 @@ namespace :scihist do end end - accession_num = w.external_id.find { |id| id.category == "interview" }&.value + accession_num = w.oral_history_number unless accession_num progress_bar.log("ERROR: #{w.title}: no accession number.") progress_bar.increment