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

CIRC-584 Remove unnecessary reference records fetches when moving requests #1134

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public MoveRequestProcessAdapter(ItemRepository itemRepository, LoanRepository l

CompletableFuture<Result<RequestAndRelatedRecords>> findDestinationItem(
RequestAndRelatedRecords requestAndRelatedRecords) {
return itemRepository.fetchById(requestAndRelatedRecords.getDestinationItemId())

return itemRepository.fetchItemWithHoldingsAndInstance(requestAndRelatedRecords.getDestinationItemId())
.thenApply(r -> r.map(requestAndRelatedRecords::withItem))
.thenComposeAsync(r -> r.after(this::findLoanForItem));
}
Expand All @@ -34,7 +35,7 @@ private CompletableFuture<Result<RequestAndRelatedRecords>> findLoanForItem(

CompletableFuture<Result<RequestAndRelatedRecords>> findSourceItem(
RequestAndRelatedRecords requestAndRelatedRecords) {
return itemRepository.fetchById(requestAndRelatedRecords.getSourceItemId())
return itemRepository.fetchItemWithHoldingsAndInstance(requestAndRelatedRecords.getSourceItemId())
.thenApply(result -> result.map(requestAndRelatedRecords::withItem))
.thenComposeAsync(r -> r.after(this::findLoanForItem));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,12 @@ private CompletableFuture<Result<MultipleRecords<Item>>> fetchItemsWithHoldingsR
.thenComposeAsync(this::fetchHoldingsRecords);
}

public CompletableFuture<Result<Item>> fetchItemWithHoldingsAndInstance(String itemId) {
return fetchItem(itemId)
.thenComposeAsync(combineAfter(this::fetchHoldingsRecord, Item::withHoldings))
.thenComposeAsync(combineAfter(this::fetchInstance, Item::withInstance));
}

public CompletableFuture<Result<Item>> fetchItemRelatedRecords(Result<Item> itemResult) {
return itemResult.combineAfter(this::fetchHoldingsRecord, Item::withHoldings)
.thenComposeAsync(combineAfter(this::fetchInstance, Item::withInstance))
Expand Down