mod-patronblocks gets all of its data (information about loans and fees/fines) from events published by mod-circulation and mod-feesfines. As a result, when the module is deployed to the environment that already has loans and fees/fines information, mod-patronblocks will never receive this information because all of the events for these loans and fees/fines have already happened.
It's proposed to add functionality ( - MODPATBLK-41Getting issue details... STATUS ) that would allow us to re-sync loans and fees/fines info on the mod-patronblocks side to make its data up-to-date. mod-patronblocks will call mod-circulation-storage and mod-feesfines API to retrieve required info and populate its own database. Considering that such a process can be quite time-consuming, it'll be performed offline to avoid web server's HTTP request timeout.
To do a re-sync:
1 - User makes a call to an endpoint:
POST /automated-patron-blocks/synchronization-request
Body:
{ "scope": string }
where "scope" accepts one of these formats:
- "full" - to re-sync data for all users
- "user:{user-uuid}" - to re-sync one patron's data, specified with UUID
Response in case of success:
{ "id": {sync-request-id}, "scope": {sync-request-scope}, "status": "open" }
Later, this object will be updated by a synchronization process and the user will be able to check synchronization status by calling an endpoint:
GET /automated-patron-blocks/synchronization-request/{sync-request-uuid}
2 - Synchronization request object is stored in the mod-patronblocks DB
3 - Okapi timer triggers the synchronization process.
Synchronization request's status is changed from "open" to "in-progress".
4 - mod-patronblocks calls mod-circulation-storage and mod-feesfines API to retrieve information about loans and fees/fines and updates its database
During this process synchronization request object in the DB is updated with:
- total number of loans
- total number of fees/fines
- number of processed loans
- number of processed fees/fines
- errors that occurred during the synchronization process
At this point, synchronization request (when retrieved via GET endpoint) will look like this:
{ "id": {sync-request-id}, "scope": {sync-request-scope}, "status": "in-progress", "totalNumberOfLoans": number, "totalNumberOfFeesFines": number, "numberOfProcessedLoans": number, "numberOfProcessedFeesFines": number, "errors": [ string ] }
which would allow the user to check the progress of the synchronization process.
5 - When the process is finished successfully, status is changed to "done". In case of a failure, status is changed to "failed".