Bug 36504 - Run report should have an option to only send the attachment
Summary: Run report should have an option to only send the attachment
Status: Failed QA
Alias: None
Product: Koha
Classification: Unclassified
Component: Command-line Utilities (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Nick Clemens (kidclamp)
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-04-03 15:33 UTC by Nick Clemens (kidclamp)
Modified: 2024-05-06 13:21 UTC (History)
2 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 36504: Add attach_only option to run report (7.24 KB, patch)
2024-04-03 15:45 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 36504: Add a test-email option (2.74 KB, patch)
2024-04-03 15:45 UTC, Nick Clemens (kidclamp)
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) 2024-04-03 15:33:10 UTC
Currently, if runreport sends results via email, they are included in the body when also supplied as an attachment. Some libraries would like to receive only the attachment, to make the email less cluttered for large reports.
Comment 1 Nick Clemens (kidclamp) 2024-04-03 15:45:39 UTC
Created attachment 164385 [details] [review]
Bug 36504: Add attach_only option to run report

To test:
1 - Create a report in Koha
2 - Have koha setup to send emails
3 - perl misc/cronjobs/runreport.pl --to="example@example.org" --subject="Report cronjob" --format=csv --csv-header -a 1
4 - Note the email body and attachment contain the results
5 - Apply this patch
6 - Repeat above
7 - Note the email body says "Repost results attached"
8 - Confirm results attached
9 - Adjust report to have 0 results
10 - perl misc/cronjobs/runreport.pl --to="example@example.org" --subject="Report cronjob" --format=csv --csv-header -a 1 --send_empty
11 - Confirm the attachment exists, but message body indicates no results
Comment 2 Nick Clemens (kidclamp) 2024-04-03 15:45:41 UTC
Created attachment 164386 [details] [review]
Bug 36504: Add a test-email option

This is not necessarily for pushing, but makes testing first patch easier as it doesn't require
setting up email. Apply this patch, and add --test-email when runnign the script.
The email object will be dumped to the screen and you can verofy the content of the body/attachment
Comment 3 David Nind 2024-04-04 23:11:26 UTC
I only used the first patch, and set up KTD to use email [1].

Using the new -ao option when the report has results: no message in the body, attachment is called 'noname' (using just -a is called 'report1-YYYY-MM-DD.csv')

Using the new -ao option when the report has no results: "No results were returned for the report" in the body and the attachment called 'report1-YYYY-MM-DD.csv'. 

So, I think this isn't working as intended when the report has results - there should be a message in the body ("Report results attached") and the report attached should be correctly named.

Full details
============

After applying the patch, if I use the -ao (or --attach_only) option:
1. The email body is empty.
2. The attached file is called 'noname'.
3. Using just -a (before and after the patch is applied), the attachment is called 'report1-YYYY-MM-DD.csv'.
4. If the report is empty (using -a or -ao) I get a message with "No results were returned for the report" in the body and the attachment called 'report1-YYYY-MM-DD.csv'. 


[1] To test sending emails using a Google account:

1. Set up an App password for your Google Account
2. 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>
Comment 4 Nick Clemens (kidclamp) 2024-04-08 13:31:14 UTC
I tested again, I couldn't get email working but the dumped email looks correct to me, could you test again? And maybe send the emails to my email so I see the problem ;-)
Comment 5 Owen Leonard 2024-05-06 13:21:20 UTC
(In reply to David Nind from comment #3)

> Using the new -ao option when the report has results: no message in the
> body, attachment is called 'noname' (using just -a is called
> 'report1-YYYY-MM-DD.csv')

Confirmed.

 
> Using the new -ao option when the report has no results: "No results were
> returned for the report" in the body and the attachment called
> 'report1-YYYY-MM-DD.csv'. 

In my test the screen output is "NO OUTPUT: 0 results from execute_query" and there is no email.