NYPL-Simplified/circulation

Allow a patron to fulfill any delivery mechanism compatible with their loan

leonardr opened this issue · 1 comments

Currently once you start using a delivery mechanism for a certain loan, you can only use that delivery mechanism. There is one exception: you can also use a streaming delivery mechanism.

I've identified a second exception: an open-access book may have multiple LicensePoolDeliveryMechanisms for the same DeliveryMechanism but different resources, either because a book was mirrored to more than one S3 bucket or because the data source from which it was imported offered multiple editions in the same format (such as Project Gutenberg's "with images" and "without images" EPUBs).

I've seen cases in the wild where a patron borrows a book, locks in a certain delivery mechanism, and then can't fulfill the book. This happens because the circulation manager turns "DeliveryMechanism #1" into "LicensePoolDeliveryMechanism #99" instead of the nearly-identical "LicensePollDeliveryMechanism #201".

So there are two problems here. First, that shouldn't happen. But also, if you lock in #201 and then somehow ask for #99, you should get #99 if it's compatible with #99.

The underlying cause of the problem is that controller.py:CirculationManagerController.load_licensepooldelivery does a lookup on LPDM with on_multiple="interchangeable" but then the LPDMs aren't actually interchangeable. Since NYPL-Simplified/server_core#814 makes all LPDMs with the same DM interchangeable in practice, that change might be good enough on its own. Or at the very least, it might put the rest into the realm of "additional improvements to be done later".