Bug 33360: Improving limit behavior in SendQueuedMessages
Includes:
[1] Do no longer use the limit in the sql selection, but apply the
limit as a maximum for the number of sent messages. This is more
practical in terms of not flooding your mail server (and the
receiving ones).
[2] Replace call of _get_unsent_messages by Koha objects search.
[3] Do no longer report the number of messages seen, but report the
number actually 'sent'.
[4] If we lookup the to_address but we need to delay a message, save
the email address for the next run. Also optimizing patron lookup
in _send_message_by_email.
[5} Add support for $where parameter in SendQueuedMessages. Used by
process_message_queue.pl.
[6] Handle scalar/array for letter_code and type parameter too.
Test plan:
[1] Adjust your domain limit settings in koha-conf.
Use notices to three domains. Group A and B.
<message_domain_limits>
<domain><name>A</name><limit>1</limit><unit>1h</unit></domain>
<domain><name>B/name><belongs_to>A</belongs_to></domain>
<domain><name>C</name><limit>1</limit><unit>1h</unit></domain>
</message_domain_limits>
Replace A, B and C with your choice. Do not forget the belongs_to.
Restart all.
[2] Disable cron job for message queue.
[3] Generate two notices for each domain A, B and C (in that order).
Make sure that borrowers involved have correct address.
[4] Run process_message_queue.pl -limit 1
[5] Check that one is sent for A, 5 pending.
[6] Run process_message_queue.pl -limit 2
[7] Check that one is sent for C, 4 pending.
[8] Run process_message_queue.pl (without limit).
[9] Check that nothing is sent, 4 pending.
[10] Check that message_queue.to_address is filled for those 4.
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>