Bug 31415 - Script to automate converting holds to recalls
Summary: Script to automate converting holds to recalls
Status: BLOCKED
Alias: None
Product: Koha
Classification: Unclassified
Component: Circulation (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Aleisha Amohia
QA Contact: Testopia
URL:
Keywords:
Depends on: 31391
Blocks: 32776
  Show dependency treegraph
 
Reported: 2022-08-18 23:38 UTC by Aleisha Amohia
Modified: 2024-09-19 01:21 UTC (History)
7 users (show)

See Also:
Change sponsored?: Sponsored
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
This patch adds a script which can be used to automatically convert the oldest hold on a record to a recall, if there are a specified minimum number of holds on the record.
Version(s) released in:
Circulation function: recalls


Attachments
Issue 1: First pass at script to automate converting to recall (7.44 KB, patch)
2022-08-18 23:39 UTC, Aleisha Amohia
Details | Diff | Splinter Review
Issue 1: Scheduling cron to convert recalls to reserves (1.31 KB, patch)
2022-08-18 23:39 UTC, Aleisha Amohia
Details | Diff | Splinter Review
Bug 31415: Script to automate converting reserves to recalls (4.55 KB, patch)
2022-08-23 02:02 UTC, Aleisha Amohia
Details | Diff | Splinter Review
Bug 31415: Script to automate converting reserves to recalls (6.66 KB, patch)
2022-08-25 02:59 UTC, Aleisha Amohia
Details | Diff | Splinter Review
Bug 31415: Script to automate converting reserves to recalls (6.70 KB, patch)
2023-01-30 10:06 UTC, David Nind
Details | Diff | Splinter Review
Bug 31415: Script to automate converting holds to recalls (6.54 KB, patch)
2023-03-12 21:14 UTC, Aleisha Amohia
Details | Diff | Splinter Review
Bug 31415: Script to automate converting holds to recalls (6.55 KB, patch)
2023-10-12 21:44 UTC, Aleisha Amohia
Details | Diff | Splinter Review
Bug 31415: Exclude found holds and fix hold ID call (1.73 KB, patch)
2023-11-15 20:49 UTC, Aleisha Amohia
Details | Diff | Splinter Review
Bug 31415: Script to automate converting holds to recalls (6.54 KB, patch)
2023-11-15 21:37 UTC, David Nind
Details | Diff | Splinter Review
Bug 31415: Exclude found holds and fix hold ID call (1.78 KB, patch)
2023-11-15 21:37 UTC, David Nind
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Aleisha Amohia 2022-08-18 23:38:07 UTC
If a record reaches X number of reserves, the library may convert reserves to recalls to prompt patrons to return them sooner. This can be automated with a script.
Comment 1 Aleisha Amohia 2022-08-18 23:39:38 UTC
Created attachment 139440 [details] [review]
Issue 1: First pass at script to automate converting to recall

(cherry picked from commit d97c04e398b857e39aed4c10406dd9805d419d31)
Comment 2 Aleisha Amohia 2022-08-18 23:39:42 UTC
Created attachment 139441 [details] [review]
Issue 1: Scheduling cron to convert recalls to reserves

(cherry picked from commit 5af81d5a5adcce07adb93915bf94e76b3066d88c)
Comment 3 Aleisha Amohia 2022-08-18 23:39:59 UTC
This is a work in progress and is not ready for testing.
Comment 4 Aleisha Amohia 2022-08-23 02:02:06 UTC
Created attachment 139646 [details] [review]
Bug 31415: Script to automate converting reserves to recalls

This is a work in progress and not ready for testing.
Comment 5 Aleisha Amohia 2022-08-25 02:59:27 UTC
Created attachment 139737 [details] [review]
Bug 31415: Script to automate converting reserves to recalls

This patch adds a script which can be used to automatically convert the
oldest reserve on a record to a recall, if there are a specified minimum
number of reserves on the record.

To test:
1) Enable UseRecalls and configure circulation rules relevant to
recalls. Keep the 'on shelf recalls allowed' setting to 'any' for the
sake of testing ('all' would require all items to be checked out for the
reserve to be converted to a recall)
2) Check out items from multiple records (at least 2 different records)
to Patron A.
3) Place multiple reserves on each record (at least 2 reserves).
4) Place multiple reserves on another record which has no items checked
out.
5) We now have multiple records where the oldest reserve is eligible for
recall, plus a record where the oldest reserve is NOT eligible for
recall (because no items are checked out).
6) In your terminal, get into the shell and run the script. -v means
verbose and will print the reserves that are converted into recalls.
--min 1 means there must be more than 1 reserve on the record to be
considered.
  sudo koha-shell INSTANCE
  perl misc/cronjobs/recalls/convert_reserves_to_recalls.pl -v --min 1
7) Confirm that, for the records where items are checked out and there
are multiple reserves, the oldest reserve was converted into a recall
8) Confirm that, for the record where no items are checked out, the
reserves all remain and not converted into a recall.
9) Confirm documentation for the script looks good
  perldoc misc/cronjobs/recalls/convert_reserves_to_recalls.pl

Sponsored-by: Auckland University of Technology
Comment 6 David Nind 2023-01-30 10:06:44 UTC
Created attachment 145796 [details] [review]
Bug 31415: Script to automate converting reserves to recalls

This patch adds a script which can be used to automatically convert the
oldest reserve on a record to a recall, if there are a specified minimum
number of reserves on the record.

To test:
1) Enable UseRecalls and configure circulation rules relevant to
recalls. Keep the 'on shelf recalls allowed' setting to 'any' for the
sake of testing ('all' would require all items to be checked out for the
reserve to be converted to a recall)
2) Check out items from multiple records (at least 2 different records)
to Patron A.
3) Place multiple reserves on each record (at least 2 reserves).
4) Place multiple reserves on another record which has no items checked
out.
5) We now have multiple records where the oldest reserve is eligible for
recall, plus a record where the oldest reserve is NOT eligible for
recall (because no items are checked out).
6) In your terminal, get into the shell and run the script. -v means
verbose and will print the reserves that are converted into recalls.
--min 1 means there must be more than 1 reserve on the record to be
considered.
  sudo koha-shell INSTANCE
  perl misc/cronjobs/recalls/convert_reserves_to_recalls.pl -v --min 1
7) Confirm that, for the records where items are checked out and there
are multiple reserves, the oldest reserve was converted into a recall
8) Confirm that, for the record where no items are checked out, the
reserves all remain and not converted into a recall.
9) Confirm documentation for the script looks good
  perldoc misc/cronjobs/recalls/convert_reserves_to_recalls.pl

Sponsored-by: Auckland University of Technology
Signed-off-by: David Nind <david@davidnind.com>
Comment 7 Kyle M Hall (khall) 2023-03-10 14:41:27 UTC
Easy to fix issue, can you please change usage of the word "reserve" to "hold" for consistency with Koha standard terminology: https://wiki.koha-community.org/wiki/Terminology#R
Comment 8 Aleisha Amohia 2023-03-12 21:14:41 UTC
Created attachment 148112 [details] [review]
Bug 31415: Script to automate converting holds to recalls

This patch adds a script which can be used to automatically convert the
oldest hold on a record to a recall, if there are a specified minimum
number of holds on the record.

To test:
1) Enable UseRecalls and configure circulation rules relevant to
recalls. Keep the 'on shelf recalls allowed' setting to 'any' for the
sake of testing ('all' would require all items to be checked out for the
hold to be converted to a recall)
2) Check out items from multiple records (at least 2 different records)
to Patron A.
3) Place multiple holds on each record (at least 2 holds).
4) Place multiple holds on another record which has no items checked
out.
5) We now have multiple records where the oldest hold is eligible for
recall, plus a record where the oldest hold is NOT eligible for
recall (because no items are checked out).
6) In your terminal, get into the shell and run the script. -v means
verbose and will print the holds that are converted into recalls.
--min 1 means there must be more than 1 hold on the record to be
considered.
  sudo koha-shell INSTANCE
  perl misc/cronjobs/recalls/convert_holds_to_recalls.pl -v --min 1
7) Confirm that, for the records where items are checked out and there
are multiple holds, the oldest hold was converted into a recall
8) Confirm that, for the record where no items are checked out, the
holds all remain and not converted into a recall.
9) Confirm documentation for the script looks good
  perldoc misc/cronjobs/recalls/convert_holds_to_recalls.pl

Sponsored-by: Auckland University of Technology
Signed-off-by: David Nind <david@davidnind.com>
Comment 9 David Nind 2023-09-24 22:06:19 UTC
I'm getting this error when running the script:

perl misc/cronjobs/recalls/convert_holds_to_recalls.pl -v --min 1

DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Unknown column 'holddate' in 'order clause' at /kohadevbox/koha/Koha/Objects.pm line 394
Comment 10 Aleisha Amohia 2023-10-12 21:44:23 UTC
Created attachment 157002 [details] [review]
Bug 31415: Script to automate converting holds to recalls

This patch adds a script which can be used to automatically convert the
oldest hold on a record to a recall, if there are a specified minimum
number of holds on the record.

To test:
1) Enable UseRecalls and configure circulation rules relevant to
recalls. Keep the 'on shelf recalls allowed' setting to 'any' for the
sake of testing ('all' would require all items to be checked out for the
hold to be converted to a recall)
2) Check out items from multiple records (at least 2 different records)
to Patron A.
3) Place multiple holds on each record (at least 2 holds).
4) Place multiple holds on another record which has no items checked
out.
5) We now have multiple records where the oldest hold is eligible for
recall, plus a record where the oldest hold is NOT eligible for
recall (because no items are checked out).
6) In your terminal, get into the shell and run the script. -v means
verbose and will print the holds that are converted into recalls.
--min 1 means there must be more than 1 hold on the record to be
considered.
  sudo koha-shell INSTANCE
  perl misc/cronjobs/recalls/convert_holds_to_recalls.pl -v --min 1
7) Confirm that, for the records where items are checked out and there
are multiple holds, the oldest hold was converted into a recall
8) Confirm that, for the record where no items are checked out, the
holds all remain and not converted into a recall.
9) Confirm documentation for the script looks good
  perldoc misc/cronjobs/recalls/convert_holds_to_recalls.pl

Sponsored-by: Auckland University of Technology
Signed-off-by: David Nind <david@davidnind.com>
Comment 11 David Nind 2023-10-17 21:41:30 UTC
I got this error message when testing again:

perl misc/cronjobs/recalls/convert_holds_to_recalls.pl -v --min 1
No reserves HOLD_CANCELLATION letter transported by email at /kohadevbox/koha/C4/Letters.pm line 588.
The method Koha::Hold->hold_id is not covered by tests!

Trace begun at /kohadevbox/koha/Koha/Object.pm line 931
Koha::Object::AUTOLOAD('Koha::Hold=HASH(0x55b1c879dd50)') called at misc/cronjobs/recalls/convert_holds_to_recalls.pl line 129

Do I need to make sure email is set up and that each of the patrons have an email address?

The records and patrons I used were from different libraries, not sure whether that should make a difference.

Setup:
1. Recalls:
   . Recalls allowed (total): 5
   . Recalls per record (count): 5 
   . On shelf recalls allowed: If any unavailable1
   . Recall due date interval (day): 5
   . Recall overdue fine amount: 5.00
   . Recall pickup period (day): 5
2. Checked out 3 items to Mary Burton (Effective Perl (139 - item 296), Perl template toolkit (255 - item 564), Programming Perl (262 - item 578))
3. Placed holds on these records:
   - Effective Perl (139): Bobbie Middleton, Henry Acevedo, Lisa Charles
   - Perl template toolkit (255): Henry Acevedo, Lisa Charles, Bobbie Middleton
   - Programming Perl (262): Henry Acevedo, Lisa Charles, Bobbie Middleton
   - The complete novels / Jane Austen (19): Mary Burton, Lisa Charles
4. After running the script, got the error above. One recall was made for:
   - Effective Perl: requested by Bobbie Middleton
Comment 12 Aleisha Amohia 2023-11-15 20:49:37 UTC
Created attachment 159010 [details] [review]
Bug 31415: Exclude found holds and fix hold ID call
Comment 13 David Nind 2023-11-15 21:37:13 UTC
Created attachment 159016 [details] [review]
Bug 31415: Script to automate converting holds to recalls

This patch adds a script which can be used to automatically convert the
oldest hold on a record to a recall, if there are a specified minimum
number of holds on the record.

To test:
1) Enable UseRecalls and configure circulation rules relevant to
recalls. Keep the 'on shelf recalls allowed' setting to 'any' for the
sake of testing ('all' would require all items to be checked out for the
hold to be converted to a recall)
2) Check out items from multiple records (at least 2 different records)
to Patron A.
3) Place multiple holds on each record (at least 2 holds).
4) Place multiple holds on another record which has no items checked
out.
5) We now have multiple records where the oldest hold is eligible for
recall, plus a record where the oldest hold is NOT eligible for
recall (because no items are checked out).
6) In your terminal, get into the shell and run the script. -v means
verbose and will print the holds that are converted into recalls.
--min 1 means there must be more than 1 hold on the record to be
considered.
  sudo koha-shell INSTANCE
  perl misc/cronjobs/recalls/convert_holds_to_recalls.pl -v --min 1
7) Confirm that, for the records where items are checked out and there
are multiple holds, the oldest hold was converted into a recall
8) Confirm that, for the record where no items are checked out, the
holds all remain and not converted into a recall.
9) Confirm documentation for the script looks good
  perldoc misc/cronjobs/recalls/convert_holds_to_recalls.pl

Sponsored-by: Auckland University of Technology
Signed-off-by: David Nind <david@davidnind.com>
Comment 14 David Nind 2023-11-15 21:37:16 UTC
Created attachment 159017 [details] [review]
Bug 31415: Exclude found holds and fix hold ID call

Signed-off-by: David Nind <david@davidnind.com>
Comment 15 David Nind 2023-11-15 21:37:50 UTC
All looks good and now working as expected.

The documentation looks fine to me.
Comment 16 Danyon Sewell 2024-09-19 01:21:57 UTC
Can this be moved to signed off now?