Bug 35171 - runreport.pl cronjob should optionally send an email when the report has no results
Summary: runreport.pl cronjob should optionally send an email when the report has no r...
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Command-line Utilities (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal (vote)
Assignee: Nick Clemens (kidclamp)
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-10-26 18:03 UTC by Nick Clemens (kidclamp)
Modified: 2023-12-18 20:50 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact: Caroline Cyr La Rose
Documentation submission: https://gitlab.com/koha-community/koha-manual/-/merge_requests/795
Text to go in the release notes:
This enhancement adds a new 'send_empty' option to runreport.pl. Currently, if there are no results for a report, then no email is sent. This option lets libraries know that a report was run overnight and that it had no results. Example: perl misc/cronjobs/runreport.pl 1 --send_empty --email
Version(s) released in:
23.11.00,23.05.06


Attachments
Bug 35171: Add send_empty option to runreport (3.68 KB, patch)
2023-10-26 18:07 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 35171: Add send_empty option to runreport (3.73 KB, patch)
2023-10-28 22:12 UTC, David Nind
Details | Diff | Splinter Review
Bug 35171: Add send_empty option to runreport (3.78 KB, patch)
2023-10-30 20:00 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 35171: (QA follow-up): tidy up POD (1.56 KB, patch)
2023-10-30 20:00 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Clemens (kidclamp) 2023-10-26 18:03:15 UTC
Some libraries would like to know that a report was run overnight, even if there were no results. We should allow this as an optional feature.
Comment 1 Nick Clemens (kidclamp) 2023-10-26 18:07:50 UTC
Created attachment 157944 [details] [review]
Bug 35171: Add send_empty option to runreport

This patch adds a new 'send_empty' option to runreport.pl

To test:
1 - Create a report in Koha that will not return any results:
    SELECT barcode FROM items WHERE 1=2
2 - perl misc/cronjobs/runreport.pl 1
3 - Output is: NO OUTPUT: 0 results from execute_query
4 - perl misc/cronjobs/runreport.pl 1 --send_empty
5 - Output is: no results were returned for the report
6 - perl misc/cronjobs/runreport.pl 1 --send_empty --email
7 - It will die on an email error unless you have SMTP configured - this si good, it means we sent an email
8 - Bonus points: Test on a system that can correctly send emails, confirm it works :-)
Comment 2 David Nind 2023-10-28 22:12:17 UTC
Created attachment 158016 [details] [review]
Bug 35171: Add send_empty option to runreport

This patch adds a new 'send_empty' option to runreport.pl

To test:
1 - Create a report in Koha that will not return any results:
    SELECT barcode FROM items WHERE 1=2
2 - perl misc/cronjobs/runreport.pl 1
3 - Output is: NO OUTPUT: 0 results from execute_query
4 - perl misc/cronjobs/runreport.pl 1 --send_empty
5 - Output is: no results were returned for the report
6 - perl misc/cronjobs/runreport.pl 1 --send_empty --email
7 - It will die on an email error unless you have SMTP configured - this si good, it means we sent an email
8 - Bonus points: Test on a system that can correctly send emails, confirm it works :-)

Signed-off-by: David Nind <david@davidnind.com>
Comment 3 David Nind 2023-10-28 22:19:24 UTC
Testing notes (using KTD):

1. I tested using email, and the email message was received

1. To test sending emails using a Google account, set up an APP password for your Google account, edit /etc/koha/sites/kohadev/koha-conf.xml file and add this configuration near the end (where <user_name> = your Google email address; <password> = your APP password, not your Google account password):

 <smtp_server>
    <host>smtp.gmail.com</host>
    <port>587</port>
    <timeout>5</timeout>
    <ssl_mode>STARTTLS</ssl_mode>
    <user_name>GOOGLEACCOUNTUSER</user_name>
    <password>GOOGLEAPPPASSWORD</password>
    <debug>1</debug>
 </smtp_server>

2. Change the KohaAdminEmailAddress system preference to a valid email address that you have access to.

3. Run flush_memcached and restart_all
Comment 4 Victor Grousset/tuxayo 2023-10-30 20:00:21 UTC
Created attachment 158102 [details] [review]
Bug 35171: Add send_empty option to runreport

This patch adds a new 'send_empty' option to runreport.pl

To test:
1 - Create a report in Koha that will not return any results:
    SELECT barcode FROM items WHERE 1=2
2 - perl misc/cronjobs/runreport.pl 1
3 - Output is: NO OUTPUT: 0 results from execute_query
4 - perl misc/cronjobs/runreport.pl 1 --send_empty
5 - Output is: no results were returned for the report
6 - perl misc/cronjobs/runreport.pl 1 --send_empty --email
7 - It will die on an email error unless you have SMTP configured - this si good, it means we sent an email
8 - Bonus points: Test on a system that can correctly send emails, confirm it works :-)

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Comment 5 Victor Grousset/tuxayo 2023-10-30 20:00:24 UTC
Created attachment 158103 [details] [review]
Bug 35171: (QA follow-up): tidy up POD
Comment 6 Victor Grousset/tuxayo 2023-10-30 20:02:03 UTC
Thanks David for the complete test :)

Works, makes sense, QA script happy, code looks good, passing QA :)
Comment 7 Tomás Cohen Arazi 2023-11-01 20:27:03 UTC
Pushed to master for 23.11.

Nice work everyone, thanks!
Comment 8 Fridolin Somers 2023-11-08 08:43:50 UTC
Pushed to 23.05.x for 23.05.06