Skip to content

Commit

Permalink
Merge pull request #819 from WGBH-MLA/sony_ci_id_again
Browse files Browse the repository at this point in the history
fix 2 for sonyci_id
  • Loading branch information
orangewolf authored Dec 21, 2023
2 parents b83fdc9 + cda7e54 commit 45216a1
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions app/indexers/asset_indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def generate_solr_document
if object.admin_data
# Index the admin_data_gid
solr_doc['admin_data_tesim'] = object.admin_data.gid if !object.admin_data.gid.blank?
solr_doc['admin_data_gid_ssim'] = object.admin_data.gid if !object.admin_data.gid.blank?
solr_doc['sonyci_id_ssim'] = object.admin_data.sonyci_id if !object.admin_data.sonyci_id.blank?

# Programmatically assign annotations by type from controlled vocab
Expand Down
1 change: 1 addition & 0 deletions app/indexers/asset_resource_indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def to_solr
if resource.admin_data
# Index the admin_data_gid
index_document['admin_data_tesim'] = resource.admin_data.gid if !resource.admin_data.gid.blank?
index_document['admin_data_gid_ssim'] = resource.admin_data.gid if !resource.admin_data.gid.blank?
index_document['sonyci_id_ssim'] = resource.admin_data.sonyci_id if !resource.admin_data.sonyci_id.blank?

# Programmatically assign annotations by type from controlled vocab
Expand Down
2 changes: 2 additions & 0 deletions app/models/bulkrax/pbcore_xml_entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def build_metadata
self.parsed_metadata["contributors"] = self.raw_metadata["contributors"]
self.parsed_metadata['bulkrax_importer_id'] = importer.id
self.parsed_metadata['admin_data_gid'] = admin_data_gid
self.parsed_metadata['sonyci_id'] = self.raw_metadata['sonyci_id']
build_annotations(self.raw_metadata['annotations']) if self.raw_metadata['annotations'].present?
end

Expand All @@ -79,6 +80,7 @@ def admin_data
end

@admin_data = work.admin_data if work.present?
@admin_data ||= AdminData.find_by_gid(self.raw_metadata['admin_data_gid']) if self.raw_metadata['admin_data_gid'].present?
@admin_data ||= AdminData.new
@admin_data.bulkrax_importer_id = importer.id
@admin_data.save
Expand Down
4 changes: 2 additions & 2 deletions app/models/solr_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class SolrDocument

# Determine which type of Fedora record this SolrDocument instance represents.
def has_model
self['has_model_ssim'].first
Array.wrap(self['has_model_ssim']).first
end

# Define boolean predicates for determining record type.
Expand Down Expand Up @@ -545,7 +545,7 @@ def all_members(only: [], exclude: [])

def admin_data_gid
return unless is_asset?
self['admin_data_gid_ssim']&.first
Array.wrap(self['admin_data_gid_ssim'] || self['admin_data_tesim']).first
end

def admin_data
Expand Down
2 changes: 1 addition & 1 deletion app/services/ams/export/delivery/aapb_delivery.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def ingester
# for the database ID here, which is not ideal.
def update_last_pushed
admin_data_ids = export_results.solr_documents.map do |solr_doc|
solr_doc['admin_data_gid_ssim'].first.sub('gid://ams/admindata/', '')
Array.wrap(solr_doc['admin_data_gid_ssim']).first.sub('gid://ams/admindata/', '')
end
AdminData.where(id: admin_data_ids).update(last_pushed: Time.now)
end
Expand Down
1 change: 1 addition & 0 deletions spec/models/bulkrax/pbcore_xml_entry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ module Bulkrax
"model"=>"AssetResource",
"id"=>"cpb-aacip-20-000000hr",
"series_title"=>["Houston Symphony"],
"sonyci_id" => ["d74384e6424246088871415afe6230f5"],
"description"=>["5/11/96"],
"episode_description"=>[],
"series_description"=>
Expand Down
3 changes: 1 addition & 2 deletions spec/services/ams/export/delivery/aapb_delivery_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# end
# end

let(:assets) { create_list(:asset, rand(2..4)) }
let(:assets) { create_list(:asset_resource, rand(2..4)) }

let(:solr_documents) do
assets.map { |asset| SolrDocument.new(asset.to_solr) }
Expand Down Expand Up @@ -57,7 +57,6 @@
# Grab a timestamp just before delivering, so we can test to make sure
# the last_pushed date for the records is updated to something afterward.
@just_before_delivery = Time.now.to_i

# call the method under test
subject.deliver
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
RSpec.describe AMS::Export::Results::PBCoreZipResults do
describe '#filepath' do
let(:solr_docs) do
create_list(:asset, rand(2..4)).map { |asset| SolrDocument.new(asset.to_solr) }
create_list(:asset_resource, rand(2..4)).map { |asset| SolrDocument.new(asset.to_solr) }
end

subject { described_class.new(solr_documents: solr_docs) }
Expand Down

0 comments on commit 45216a1

Please sign in to comment.