Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/components/work_show_info_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/works_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 1 addition & 7 deletions app/models/oral_history_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions app/models/work.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand Down
4 changes: 1 addition & 3 deletions app/presenters/citable_attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down