-
Notifications
You must be signed in to change notification settings - Fork 0
Provide filled out item data when returning hold list #224
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
Changes from all commits
6082a62
9b2e276
e2edb84
aaf731f
87aa0f6
dee9e42
67383fc
ad8f155
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,13 @@ | ||
| package weco.api.requests.responses | ||
|
|
||
| import akka.http.scaladsl.server.Route | ||
| import weco.api.search.elasticsearch.ElasticsearchError | ||
| import weco.api.stacks.models.display.DisplayResultsList | ||
| import weco.api.search.rest.CustomDirectives | ||
| import weco.api.stacks.models.StacksHold | ||
| import weco.api.stacks.services.{ItemLookup, SierraService} | ||
| import weco.catalogue.internal_model.identifiers.IdState | ||
| import weco.catalogue.internal_model.work.Item | ||
| import weco.sierra.models.identifiers.SierraPatronNumber | ||
|
|
||
| import scala.concurrent.{ExecutionContext, Future} | ||
|
|
@@ -21,16 +25,18 @@ trait LookupPendingRequests extends CustomDirectives { | |
| userHolds <- sierraService.getStacksUserHolds(patronNumber) | ||
|
|
||
| holdsWithCatalogueIds <- Future.sequence( | ||
| userHolds.right.get.holds.map { hold => | ||
| userHolds.right.get.holds.map { hold: StacksHold => | ||
| itemLookup | ||
| .bySourceIdentifier(hold.sourceIdentifier) | ||
| .map { | ||
| case Left(elasticError) => | ||
| warn(s"Unable to look up $hold in Elasticsearch") | ||
| case Left(elasticError: ElasticsearchError) => | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Previously we just chucked this error, not sure why - i've added it to the warning here. |
||
| warn( | ||
| s"Unable to look up $hold in Elasticsearch: ${elasticError}" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's not address it here for the sake of getting this PR out quickly, but having a sourceIdentifier on the hold feels a bit odd to me – a hold is a thing in Sierra and could have a source identifier, it's just not the identifier we're using here.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What will happen in this branch if we can't find the item?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I agree, we use it to look up the item later and fill the Item option on
Good point. I think this is actually a case that will blow up the |
||
| ) | ||
| hold | ||
|
|
||
| case Right(item) => | ||
| hold.copy(canonicalId = Some(item.id.canonicalId)) | ||
| case Right(item: Item[IdState.Identified]) => | ||
| hold.copy(item = Some(item)) | ||
| } | ||
| } | ||
| ) | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -67,12 +67,16 @@ class RequestsApiFeatureTest | |||||
| ) | ||||||
| ) | ||||||
|
|
||||||
| val titleString = randomAlphanumeric(length = 20) | ||||||
|
|
||||||
| val item = createIdentifiedItemWith( | ||||||
| sourceIdentifier = SourceIdentifier( | ||||||
| identifierType = SierraSystemNumber, | ||||||
| value = itemNumber.withCheckDigit, | ||||||
| ontologyType = "Item" | ||||||
| ) | ||||||
| ), | ||||||
| locations = List.empty, | ||||||
| title = Some(titleString) | ||||||
| ) | ||||||
|
|
||||||
| val lookup = new MemoryItemLookup(items = Seq(item)) | ||||||
|
|
@@ -98,6 +102,7 @@ class RequestsApiFeatureTest | |||||
| | "type" : "Identifier" | ||||||
| | } | ||||||
| | ], | ||||||
| | "title" : "${titleString}", | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit:
Suggested change
|
||||||
| | "locations" : [ | ||||||
| | ], | ||||||
| | "type" : "Item" | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll refactor this next, but to speed up getting this data into the front-end we could merge this PR, deploy and put the refactor into a new PR.