Bug 18414 - Add ability to pass a file of borrowernumbers for deletion to delete_patrons.pl
Summary: Add ability to pass a file of borrowernumbers for deletion to delete_patrons.pl
Status: Pushed to master
Alias: None
Product: Koha
Classification: Unclassified
Component: Command-line Utilities (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Rogan Hamby
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-04-11 13:32 UTC by Katrin Fischer
Modified: 2020-05-18 14:05 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Who signed the patch off:
Text to go in the release notes:
Adds the ability to specify a file with the --file flag that should be a list of borrowernumbers for deletion. If used without other flags it will delete the list of borrowers, if used with other flags it will treat the other criteria as filters for the list.
Version(s) released in:
20.05.00


Attachments
Bug 18414 allow delete_patrons.pl to use a list of borrowernumbers (4.79 KB, patch)
2019-10-11 12:55 UTC, Rogan Hamby
Details | Diff | Splinter Review
Bug 18413: Allow to use other select criteria with delete_patrons.pl (4.89 KB, patch)
2019-12-22 14:13 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 18413: Allow to use other select criteria with delete_patrons.pl (4.95 KB, patch)
2020-03-20 13:54 UTC, Kyle M Hall
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Katrin Fischer 2017-04-11 13:32:58 UTC
It would be nice if the delete_patrons.pl script could be enhanced to also allow to delete patrons using a list of borrowernumbers from a file.
Comment 1 Rogan Hamby 2019-10-11 12:55:53 UTC
Created attachment 94015 [details] [review]
Bug 18414 allow delete_patrons.pl to use a list of borrowernumbers

Small patch to allow use of borrowernumbers in a text file for deletion.  If used with filters specified they act as filters on the contents of the file.
Comment 2 Katrin Fischer 2019-12-22 14:13:59 UTC
Created attachment 96574 [details] [review]
Bug 18413: Allow to use other select criteria with delete_patrons.pl

Adds the ability to specify a file with the --file flag that
should be a list of borrowernumbers for deletion.
If used without other flags it will delete the list of borrowers,
if used with other flags it will treat the other criteria
as filters for the list.

To Test:
1) Specify a list, e.g. borrowers.txt, of borrowernumbers in the database and put them in a text file with one per line
2) Invoke the script like ./delete_patrons.pl --file borrowers.txt to delete those patrons
3) Populate the list with a mix of borrowers in a category and those not, say categoryfoo
4) Invoke the scirpt as ./delete_patrons.pl --category_code categoryfoo --file borrowers.txt
5) Only the borrowers in the file that have the specified category will be deleted

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 3 Jonathan Druart 2019-12-23 12:44:28 UTC
I did not test but reading the code I think that there could be an expected behaviors if you pass --file with another criteria but GetBorrowersToExpunge returns an empty list
=> Patrons from the file will be deleted
Comment 4 Jonathan Druart 2019-12-23 12:48:12 UTC
Forget that last comment, it does not. You are testing for !defined $members and GetBorrowersToExpunge will always return an arrayref.
I would prefer to see the code improved and more robust to avoid such regressions if we modify the return value.

I cannot think of something right now, leaving for another QAer or will come back later to this.
Comment 5 Kyle M Hall 2020-03-20 13:54:14 UTC
Created attachment 101116 [details] [review]
Bug 18413: Allow to use other select criteria with delete_patrons.pl

Adds the ability to specify a file with the --file flag that
should be a list of borrowernumbers for deletion.
If used without other flags it will delete the list of borrowers,
if used with other flags it will treat the other criteria
as filters for the list.

To Test:
1) Specify a list, e.g. borrowers.txt, of borrowernumbers in the database and put them in a text file with one per line
2) Invoke the script like ./delete_patrons.pl --file borrowers.txt to delete those patrons
3) Populate the list with a mix of borrowers in a category and those not, say categoryfoo
4) Invoke the scirpt as ./delete_patrons.pl --category_code categoryfoo --file borrowers.txt
5) Only the borrowers in the file that have the specified category will be deleted

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

https://bugs.koha-community.org/show_bug.cgi?id=18414

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 6 Martin Renvoize 2020-03-24 10:42:40 UTC
Nice work everyone!

Pushed to master for 20.05
Comment 7 Joy Nelson 2020-04-03 21:36:17 UTC
enhancement not backported to 19.11.x