Bug 31453

Summary: Add ability to filter messages to process using process_message_queue.pl via a command line parameter
Product: Koha Reporter: Kyle M Hall (khall) <kyle>
Component: Command-line UtilitiesAssignee: Kyle M Hall (khall) <kyle>
Status: RESOLVED FIXED QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: m.de.rooy, martin.renvoize, rcoert, robin, victor
Version: unspecified   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33360
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
23.05.00
Circulation function:
Attachments: Bug 31453: Add ability to skip processing messages in message queue based on message contents
Bug 31453: Add ability to skip processing messages in message queue based on message contents
Bug 31453: Add ability to filter messages to process using process_message_queue.pl via a command line parameter
Bug 31453: Add ability to filter messages to process using process_message_queue.pl via a command line parameter
Bug 31453: Add ability to filter messages to process using process_message_queue.pl via a command line parameter

Description Kyle M Hall (khall) 2022-08-24 17:54:35 UTC
It would be very useful to be able to tell process_message_queue.pl to skip processing some messages. This is particularly useful where a plugin handles sending some message using the before_send_messages hook, but while that plugin is processing, more messages meant for the plugin might be queued. At that point, control moves back to the script and SendQueuedMessages is called, and those messages end up being processed there instead of by the plugin.
Comment 1 Kyle M Hall (khall) 2022-08-24 18:35:53 UTC
Created attachment 139736 [details] [review]
Bug 31453: Add ability to skip processing messages in message queue based on message contents

It would be very useful to be able to tell process_message_queue.pl to skip processing some messages. This is particularly useful where a plugin handles sending some message using the before_send_messages hook, but while that plugin is processing, more messages meant for the plugin might be queued. At that point, control moves back to the script and SendQueuedMessages is called, and those messages end up being processed there instead of by the plugin.

Test Plan:
1) Apply this patch
2) Queue two messages, each with a unique word
3) Run process_message_queue --content-not-like "WORD"
   where WORD is a unique word in one of the two message
4) Note the message containing "WORD" was not processed
5) prove t/db_dependent/Letters.t
Comment 2 Kyle M Hall (khall) 2022-08-26 13:27:55 UTC
Created attachment 139828 [details] [review]
Bug 31453: Add ability to skip processing messages in message queue based on message contents

It would be very useful to be able to tell process_message_queue.pl to skip processing some messages. This is particularly useful where a plugin handles sending some message using the before_send_messages hook, but while that plugin is processing, more messages meant for the plugin might be queued. At that point, control moves back to the script and SendQueuedMessages is called, and those messages end up being processed there instead of by the plugin.

Test Plan:
1) Apply this patch
2) Queue two messages, each with a unique word
3) Run process_message_queue --content-not-like "WORD"
   where WORD is a unique word in one of the two message
4) Note the message containing "WORD" was not processed
5) prove t/db_dependent/Letters.t
Comment 3 Kyle M Hall (khall) 2022-11-01 17:16:09 UTC
Created attachment 142895 [details] [review]
Bug 31453: Add ability to filter messages to process using process_message_queue.pl via a command line parameter

It would be very useful to be able to tell process_message_queue.pl to skip processing some messages. This is particularly useful where a plugin handles sending some message using the before_send_messages hook, but while that plugin is processing, more messages meant for the plugin might be queued. At that point, control moves back to the script and SendQueuedMessages is called, and those messages end up being processed there instead of by the plugin.

Test Plan:
1) Apply this patch
2) Queue two messages, each with a unique word
3) Run process_message_queue --where "content NOT LIKE '%WORD%'"
   where WORD is a unique word in one of the two message
4) Note the message containing "WORD" was not processed
5) prove t/db_dependent/Letters.t
Comment 4 Andrew Fuerste-Henry 2023-01-27 15:24:20 UTC
Created attachment 145756 [details] [review]
Bug 31453: Add ability to filter messages to process using process_message_queue.pl via a command line parameter

It would be very useful to be able to tell process_message_queue.pl to skip processing some messages. This is particularly useful where a plugin handles sending some message using the before_send_messages hook, but while that plugin is processing, more messages meant for the plugin might be queued. At that point, control moves back to the script and SendQueuedMessages is called, and those messages end up being processed there instead of by the plugin.

Test Plan:
1) Apply this patch
2) Queue two messages, each with a unique word
3) Run process_message_queue --where "content NOT LIKE '%WORD%'"
   where WORD is a unique word in one of the two message
4) Note the message containing "WORD" was not processed
5) prove t/db_dependent/Letters.t

Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Comment 5 Victor Grousset/tuxayo 2023-02-28 06:04:21 UTC
Created attachment 147478 [details] [review]
Bug 31453: Add ability to filter messages to process using process_message_queue.pl via a command line parameter

It would be very useful to be able to tell process_message_queue.pl to skip processing some messages. This is particularly useful where a plugin handles sending some message using the before_send_messages hook, but while that plugin is processing, more messages meant for the plugin might be queued. At that point, control moves back to the script and SendQueuedMessages is called, and those messages end up being processed there instead of by the plugin.

Test Plan:
1) Apply this patch
2) Queue two messages, each with a unique word
3) Run process_message_queue --where "content NOT LIKE '%WORD%'"
   where WORD is a unique word in one of the two message
4) Note the message containing "WORD" was not processed
5) prove t/db_dependent/Letters.t

Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Comment 6 Victor Grousset/tuxayo 2023-02-28 06:06:35 UTC
Works, QA script happy, code looks good, passing QA :)
Comment 7 Tomás Cohen Arazi (tcohen) 2023-03-02 12:39:24 UTC
Pushed to master for 23.05.

Nice work everyone, thanks!
Comment 8 Marcel de Rooy 2023-04-07 09:41:33 UTC
I am stumbling over this while doing changes in SendQueuedMessages on bug 33360.
I would need to convert the SQL condition into DBIx constructs since I am switching to a Koha object search instead of calling get_unsent_messages.
Any clues how to resolve that?
Comment 9 Marcel de Rooy 2023-04-07 09:46:24 UTC
<Joubu> marcelr: 33360 - see misc/cronjobs/membership_expiry.pl:199 $upcoming_mem_expires = $upcoming_mem_expires->search( \$where_literal ) if @where;