UXPROD-3738 Circulation log update: deleted item records

JIRA task

UXPROD-3738 - Getting issue details... STATUS

Architect review
PO review
TL review

Context

Circulation log reflects actions performed on items, and every log record has a link from an item barcode to item details. If an item record is deleted, and a user clicks on the item barcode from the Circulation log, an error occurs. This is a poor user experience and should be updated.

(warning) IMPORTANT: What is the expected behavior when deleting holding or instance? Is there any correlation with mark for deletion functionality that is discussed everywhere and around lately?

Analysis & Solution

The simplest and most trivial solution is to leave the existing functionality, but add error analysis when accessing the Inventory, and in case of a not found error, show the user a clear message item has been deleted. However, it must be understood that the display of such a message is possible only as a reaction to the user's action.

Based on discussions with PO, the task is to ensure that in the Circulation log application, when displaying a list of records, an icon with a warning and a pop-up message would immediately be shown, and there would be no link on the barcode itself, for those items which have been deleted.

The option with API calls from Circulation log to Inventory for each record / item before displaying is not suitable, because it 1) requires a large number of calls between applications and therefore 2) slows down the display of the log.

Therefore, in each record of the Circulation log itself, there should be a note (flag) about whether the item is active or deleted. And further, the Circulation log should be notified of all cases of deletion of items and mark the deletion in the corresponding entries. This approach allows us to solve the problem and at the same time is easy to implement.

At the same time, it turns out that if the item is deleted, only the barcode will remain in the Circulation log and no more information about which item this record is about. Therefore, as an addition to the original task, in each Circulation log record, when it is saved, one can add a snapshot with several details about the item (for example, title, author, or something similar - the list of fields can be discussed later). As a result, when displaying the Circulation log details, the user will be able to see some details about the item right away. And then, if there is an item, he/she will be able to follow the link to the full description, and for the deleted item, the corresponding message will be visible, but there will be no link. This can improve the user experience in this part. Note: the snapshot functionality mentioned in the last paragraph can be considered as a separate, additional feature that can be added later.

Solution technical details

IMPORTANT: the solution is based on the assumption that eventual consistency is allowed in this case. Eventual consistency in this context means that if an item is deleted in Inventory, a note about this in the Circulation log will appear not at the same time, but after some time. Allowed time interval is discussable. (warning)

Involved modules:

  • mod-inventory-storage - owns all the information about items and instances,
  • mod-audit - provides Circulation log functionality.

Note: An item cannot be deleted without mod-inventory-storage being involved. It can happen without mod-inventory being involved. Therefore, mod-inventory-storage in this scenario is the owner of the relevant information about the items.

Below is the sample of Circulation log record. It is proposed to add a boolean field itemIsDeleted to this structure.

logRecord.sample.json
{
  "eventId":"d194da0d-e946-440f-bba4-894a631ecfe9",
  "userBarcode": "1000024158",
  "items": [
    {
      "itemBarcode": "12983765",
      "itemId": "cb20f34f-b773-462f-a091-b233cc96b9e6",
      "itemIsDeleted": "true",
      "instanceId": "30fcc8e7-a019-43f4-b642-2edc389f4501",
      "holdingId": "133a7916-f05e-4df4-8f7f-09eb2a7076d1",
      "loanId": "cf23adf0-61ba-4887-bf82-956c4aae2260"
    }
  ],
  "object": "Loan",
  "action": "Checked out",
  "date": "2020-08-12T12:21:21.123",
  "servicePointId": "7c5abc9f-f3d7-4856-b8d7-6712462ca007",
  "source": "Truesdale, Yanic",
  "description": "Checked out to proxy",
  "linkToIds": {
    "userId": "df7f4993-8c14-4a0f-ab63-93975ab01c76"
  }
}

Important: data migration will also be required to populate this field for all records already stored in a particular Circulation log. Alternatively, re-synchronization can be applied here though some implementation most likely will be required to support this.

Next, one need implement the approach described in the FOLIO Cross-Application Data Sync Solution. In fact, this is the same event-driven approach that is already being used in some parts of FOLIO. The good news is that mod-inventory-storage has already implemented the generation and sending of change events (including deletions of items) to the Kafka topic. Therefore, in the scope of this task, one only need to implement the Event Consumer in mod-audit to check for events and flag itemIsDeleted if necessary. On FOLIO one can find examples of such Event Consumers.

Important: one will need to add an index on the itemId field to the mod-audit data schema in order to quickly search for records by this field.

If the proposal to store snapshots with selected item data in records of the Circulation log is approved, then the scheme will also need to be extended, as well as adding saving snapshots when creating Circulation log records.

Estimates

T-shirt estimates discussed with Viachaslau Khandramai (Unlicensed):

  • XXL for Kafka client and one boolean flag,
  • Jambo for the extended proposal with storing of item data snapshot.