We are often asked if an email was sent to a patron, and despite not having 100% confirmation that the message reached the person, it feels bad when fines are attached to it and no information's left in the database for our librarians. A new patch would let certain messages stay in the database, despite their age, based on their letter_code.
Created attachment 77756 [details] [review] BZ 21214: cleanup_database.pl --keep-lc to dodge deletion in message_queue based on letter_code Librarians sometime worry if a certain email was sent or not to a patron (PREDUES, ODUES, etc.), and iirc, there are no way to have that information once the cleanup_database.pl has run, unless we dig back an archive of their database. This patch would let an admin choose which letters to keep in the message_queue, based on its letter_code, by passing a comma-separated list to the script. TEST PLAN: 1) Either you have already have data, or you'll want to add some new test lines in your message_queue table . INSERT INTO message_queue(borrowernumber,letter_code,message_transport_type,status,time_queued) VALUES(1,<YOUR CODE OF CHOICE>,'email','sent','2018-01-01 00:00:42'); 2) Make a backup of this table 3) Run the script patchless with the --mail 1 option 3.1) Messages older than 1 day should have been deleted 4) Put the data back in 5) Apply patch 6) Choose a letter_code you'd like to keep, and run the script with --mail 1 --keep-lc <CODE1>[,<CODE2>] 7) Messages older than 1 day that don't have the code <CODE1> [or <CODE2>] should've been deleted
Created attachment 77762 [details] [review] Bug 21214: cleanup_database.pl --keep-lc to dodge deletion in message_queue based on letter_code Librarians sometime worry if a certain email was sent or not to a patron (PREDUES, ODUES, etc.), and iirc, there are no way to have that information once the cleanup_database.pl has run, unless we dig back an archive of their database. This patch would let an admin choose which letters to keep in the message_queue, based on its letter_code, by passing a comma-separated list to the script. TEST PLAN: 1) Either you have already have data, or you'll want to add some new test lines in your message_queue table . INSERT INTO message_queue(borrowernumber,letter_code,message_transport_type,status,time_queued) VALUES(1,<YOUR CODE OF CHOICE>,'email','sent','2018-01-01 00:00:42'); 2) Make a backup of this table 3) Run the script patchless with the --mail 1 option 3.1) Messages older than 1 day should have been deleted 4) Put the data back in 5) Apply patch 6) Choose a letter_code you'd like to keep, and run the script with --mail 1 --keep-lc <CODE1>[,<CODE2>] 7) Messages older than 1 day that don't have the code <CODE1> [or <CODE2>] should've been deleted
Hi Charles, please don't forget to assign the bug to yourself when providing a patch!
Hi, there is a problem in the code -> 243 my $quoted_codes = ''; 244 if ($letter_codes) { 245 my @codes = map { "'$_'" } split(',', $letter_codes); -> 246 my $quoted_codes = join(',', @codes); 247 } Two "my $quoted_codes", in lines 243 and 246. $quoted_codes passed to execute will always be empty. Remove the second 'my'
Created attachment 112992 [details] [review] Bug 21214: I changed cleanup_database.pl and some corrections with --keep-lc to dodge deletion in message_queue based on letter_code
Created attachment 112993 [details] [review] Bug 21214: cleanup_database.pl --keep-lc to dodge deletion in message_queue based on letter_code Librarians sometime worry if a certain email was sent or not to a patron (PREDUES, ODUES, etc.), and iirc, there are no way to have that information once the cleanup_database.pl has run, unless we dig back an archive of their database. This patch would let an admin choose which letters to keep in the message_queue, based on its letter_code, by passing a comma-separated list to the script. TEST PLAN: 1) Either you have already have data, or you'll want to add some new test lines in your message_queue table . INSERT INTO message_queue(borrowernumber,letter_code,message_transport_type,status,time_queued) VALUES(1,<YOUR CODE OF CHOICE>,'email','sent','2018-01-01 00:00:42'); 2) Make a backup of this table 3) Run the script patchless with the --mail 1 option 3.1) Messages older than 1 day should have been deleted 4) Put the data back in 5) Apply patch 6) Choose a letter_code you'd like to keep, and run the script with --mail 1 --keep-lc <CODE1>[,<CODE2>] 7) Messages older than 1 day that don't have the code <CODE1> [or <CODE2>] should've been deleted
Created attachment 112994 [details] [review] Bug 21214: I changed cleanup_database.pl and some corrections with --keep-lc to dodge deletion in message_queue based on letter_code
Created attachment 113002 [details] [review] Bug_21214: Changes after merge
Created attachment 113008 [details] [review] Bug 21214: cleanup_database.pl --keep-lc to dodge deletion in message_queue based on letter_code Librarians sometime worry if a certain email was sent or not to a patron (PREDUES, ODUES, etc.), and iirc, there are no way to have that information once the cleanup_database.pl has run, unless we dig back an archive of their database. This patch would let an admin choose which letters to keep in the message_queue, based on its letter_code, by passing a comma-separated list to the script. TEST PLAN: 1) Either you have already have data, or you'll want to add some new test lines in your message_queue table . INSERT INTO message_queue(borrowernumber,letter_code,message_transport_type,status,time_queued) VALUES(1,<YOUR CODE OF CHOICE>,'email','sent','2018-01-01 00:00:42'); 2) Make a backup of this table 3) Run the script patchless with the --mail 1 option 3.1) Messages older than 1 day should have been deleted 4) Put the data back in 5) Apply patch 6) Choose a letter_code you'd like to keep, and run the script with --mail 1 --keep-lc <CODE1>[,<CODE2>] 7) Messages older than 1 day that don't have the code <CODE1> [or <CODE2>] should've been deleted
Created attachment 113009 [details] [review] Bug_21214: Change of SQL request in condition $mail with letter_code and code modification
Created attachment 148622 [details] [review] Bug 21214: cleanup_database.pl --keep-lc to dodge deletion in message_queue based on letter_code Librarians sometime worry if a certain email was sent or not to a patron (PREDUES, ODUES, etc.), and iirc, there are no way to have that information once the cleanup_database.pl has run, unless we dig back an archive of their database. This patch would let an admin choose which letters to keep in the message_queue, based on its letter_code, by passing a comma-separated list to the script. TEST PLAN: 1) Either you have already have data, or you'll want to add some new test lines in your message_queue table . INSERT INTO message_queue(borrowernumber,letter_code,message_transport_type,status,time_queued) VALUES(1,<YOUR CODE OF CHOICE>,'email','sent','2018-01-01 00:00:42'); 2) Make a backup of this table 3) Run the script patchless with the --mail 1 option 3.1) Messages older than 1 day should have been deleted 4) Put the data back in 5) Apply patch 6) Choose a letter_code you'd like to keep, and run the script with --mail 1 --keep-lc <CODE1>[,<CODE2>] 7) Messages older than 1 day that don't have the code <CODE1> [or <CODE2>] should've been deleted
Created attachment 148623 [details] [review] Bug_21214: Change of SQL request in condition $mail with letter_code and code modification
Rebase
Created attachment 148624 [details] [review] Bug 21214: (fix) Change letter_code with letter_id in the sql query and code modification
Created attachment 148625 [details] [review] Bug 21214: (fix) Rebuild the sql query
Created attachment 158679 [details] [review] Bug 21214: cleanup_database.pl --keep-lc to dodge deletion in message_queue based on letter_code Librarians sometime worry if a certain email was sent or not to a patron (PREDUES, ODUES, etc.), and iirc, there are no way to have that information once the cleanup_database.pl has run, unless we dig back an archive of their database. This patch would let an admin choose which letters to keep in the message_queue, based on its letter_code, by passing a comma-separated list to the script. TEST PLAN: 1) Either you have already have data, or you'll want to add some new test lines in your message_queue table . INSERT INTO message_queue(borrowernumber,letter_code,message_transport_type,status,time_queued) VALUES(1,<YOUR CODE OF CHOICE>,'email','sent','2018-01-01 00:00:42'); 2) Make a backup of this table 3) Run the script patchless with the --mail 1 option 3.1) Messages older than 1 day should have been deleted 4) Put the data back in 5) Apply patch 6) Choose a letter_code you'd like to keep, and run the script with --mail 1 --keep-lc <CODE1>[,<CODE2>] 7) Messages older than 1 day that don't have the code <CODE1> [or <CODE2>] should've been deleted Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Created attachment 158680 [details] [review] Bug_21214: Change of SQL request in condition $mail with letter_code and code modification Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Created attachment 158681 [details] [review] Bug 21214: (fix) Rebuild the sql query Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Works as described.
Created attachment 162064 [details] [review] Bug 21214: cleanup_database.pl rebase to master Librarians sometime worry if a certain email was sent or not to a patron (PREDUES, ODUES, etc.), and iirc, there are no way to have that information once the cleanup_database.pl has run, unless we dig back an archive of their database. This patch would let an admin choose which letters to keep in the message_queue, based on its letter_code, by passing a comma-separated list to the script. TEST PLAN: 1) Either you have already have data, or you'll want to add some new test lines in your message_queue table . INSERT INTO message_queue(borrowernumber,letter_code,message_transport_type,status,time_queued) VALUES(1,<YOUR CODE OF CHOICE>,'email','sent','2018-01-01 00:00:42'); 2) Make a backup of this table 3) Run the script patchless with the --mail 1 option 3.1) Messages older than 1 day should have been deleted 4) Put the data back in 5) Apply patch 6) Choose a letter_code you'd like to keep, and run the script with --mail 1 --keep-lc <CODE1>[,<CODE2>] 7) Messages older than 1 day that don't have the code <CODE1> [or <CODE2>] should've been deleted
Rebase to master