Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle holding records that have neither a chronology nor enumeration #1016

Merged
merged 1 commit into from
Jul 26, 2023
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 lib/folio/mhld_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def latest_received(holding_id)
return unless latest_piece && order_is_ongoing_and_open?(latest_piece)

enumeration = latest_piece['enumeration'] # may not be present
chronology = latest_piece.fetch('chronology')
chronology = latest_piece['chronology'] # may not be present
enumeration ? "#{enumeration} (#{chronology})" : chronology
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to tweak the string output in that case?

Suggested change
enumeration ? "#{enumeration} (#{chronology})" : chronology
enumeration && chronology ? "#{enumeration} (#{chronology})" : enumeration || chronology

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It currently looks to have parity with what is coming out of Symphony, so I see no reason to make adjustments there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised we'd leave a blank () sitting around if there was an enumeration but not a chronology, but it's difficult to deciphering the existing logic and/or translate the MHLD fields to FOLIO data.

Is this the equivalent code?
https://github.com/sul-dlss/searchworks_traject_indexer/blob/main/lib/mhld_field.rb#L57-L62

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know. This was just to fix the missing method error. If you think there's an error in the output, I would prefer that we make that a new issue, find an example record and add a test to show the behavior we want.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤷‍♂️

end

Expand Down
83 changes: 83 additions & 0 deletions spec/lib/folio/mhld_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -329,4 +329,87 @@

it { is_expected.to eq ['GREEN -|- CURRENTPER -|- Latest issues in CURRENT PERIODICALS; earlier issues in STACKS -|- 2018 -|- JUN 2022'] }
end

context 'when pieces is present and has no enumeration or chronology' do
let(:holdings) do
[
{ 'id' => '5de47999-ea02-501c-b99c-512669581b81',
'hrid' => 'ah3225044_2',
'notes' => [],
'_version' => 1,
'metadata' =>
{ 'createdDate' => '2023-05-06T12:15:24.413Z',
'updatedDate' => '2023-05-06T12:15:24.413Z',
'createdByUserId' => '3e2ed889-52f2-45ce-8a30-8767266f07d2',
'updatedByUserId' => '3e2ed889-52f2-45ce-8a30-8767266f07d2' },
'sourceId' => '036ee84a-6afd-4c3c-9ad3-4a12ab875f59',
'boundWith' => nil,
'formerIds' => [],
'illPolicy' => nil,
'copyNumber' => '1',
'instanceId' => 'c4a0abd3-6705-5490-b72c-7a73a741b4c1',
'holdingsType' => { 'id' => 'e6da6c98-6dd0-41bc-8b4b-cfd4bbd9c3ae', 'name' => 'Serial', 'source' => 'folio' },
'holdingsItems' => [],
'callNumberType' => { 'id' => '95467209-6d7b-468b-94df-0f5d7ad2747d', 'name' => 'Library of Congress classification', 'source' => 'folio' },
'holdingsTypeId' => 'e6da6c98-6dd0-41bc-8b4b-cfd4bbd9c3ae',
'callNumberTypeId' => '95467209-6d7b-468b-94df-0f5d7ad2747d',
'electronicAccess' => [],
'bareHoldingsItems' => [],
'discoverySuppress' => false,
'holdingsStatements' => [{ 'note' => 'Library has latest full year only' }],
'statisticalCodeIds' => [],
'administrativeNotes' => [],
'effectiveLocationId' => '5ecf146b-ce87-42f2-aa63-00d085e82d81',
'permanentLocationId' => '5ecf146b-ce87-42f2-aa63-00d085e82d81',
'suppressFromDiscovery' => false,
'holdingsStatementsForIndexes' => [],
'holdingsStatementsForSupplements' => [],
'location' =>
{ 'effectiveLocation' =>
{ 'id' => '5ecf146b-ce87-42f2-aa63-00d085e82d81',
'code' => 'LAW-STACKS1',
'name' => 'Law 1st Floor Stacks',
'campus' => { 'id' => '7003123d-ef65-45f6-b469-d2b9839e1bb3', 'code' => 'LAW', 'name' => 'Law School' },
'details' => nil,
'library' => { 'id' => '7e4c05e3-1ce6-427d-b9ce-03464245cd78', 'code' => 'LAW', 'name' => 'Robert Crown Law' },
'isActive' => true,
'institution' => { 'id' => '8d433cdd-4e8f-4dc1-aa24-8a4ddb7dc929', 'code' => 'SU', 'name' => 'Stanford University' } },
'permanentLocation' =>
{ 'id' => '5ecf146b-ce87-42f2-aa63-00d085e82d81',
'code' => 'LAW-STACKS1',
'name' => 'Law 1st Floor Stacks',
'campus' => { 'id' => '7003123d-ef65-45f6-b469-d2b9839e1bb3', 'code' => 'LAW', 'name' => 'Law School' },
'details' => nil,
'library' => { 'id' => '7e4c05e3-1ce6-427d-b9ce-03464245cd78', 'code' => 'LAW', 'name' => 'Robert Crown Law' },
'isActive' => true,
'institution' => { 'id' => '8d433cdd-4e8f-4dc1-aa24-8a4ddb7dc929', 'code' => 'SU', 'name' => 'Stanford University' } } } }
]
end

let(:holding_summaries) do
[{ 'poLineId' => '253a67d4-2a17-472d-81d4-3afc8db2b062',
'orderType' => 'Ongoing',
'orderStatus' => 'Open',
'poLineNumber' => '6102L00-1',
'orderSentDate' => '2000-08-22T08:00:00.000+00:00',
'orderCloseReason' => nil,
'polReceiptStatus' => 'Ongoing' }]
end

let(:pieces) do
[{ 'id' => '3ceb55f5-8a63-431f-a6ee-afe5029cd406',
'format' => 'Physical',
'itemId' => 'bb963566-b400-4c59-94f3-18fd676353fe',
'titleId' => '08a59b0f-099b-47f4-82e0-e6fa22e4a510',
'poLineId' => '253a67d4-2a17-472d-81d4-3afc8db2b062',
'holdingId' => '5de47999-ea02-501c-b99c-512669581b81',
'copyNumber' => 'test',
'supplement' => false,
'receivedDate' => '2023-06-22T22:39:26.113+00:00',
'receivingStatus' => 'Received',
'displayOnHolding' => true }]
end

it { is_expected.to eq ['LAW -|- STACKS-1 -|- Library has latest full year only -|- -|- '] }
end
end