Bug 18414

Summary: Add ability to pass a file of borrowernumbers for deletion to delete_patrons.pl
Product: Koha Reporter: Katrin Fischer <katrin.fischer>
Component: Command-line UtilitiesAssignee: Rogan Hamby <rogan.hamby>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: 1joynelson, jonathan.druart, martin.renvoize, robin, rogan.hamby
Version: master   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
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
Bug 18413: Allow to use other select criteria with delete_patrons.pl
Bug 18413: Allow to use other select criteria with delete_patrons.pl

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