Bug 17350

Summary: Add option to delete data stored in saved_reports with cleanup_database
Product: Koha Reporter: Katrin Fischer <katrin.fischer>
Component: ReportsAssignee: Andrew Fuerste-Henry <andrewfh>
Status: RESOLVED FIXED QA Contact: Katrin Fischer <katrin.fischer>
Severity: enhancement    
Priority: P5 - low CC: andrewfh, aspencatteam, danielle, jens.weber, josef.moravec, jzairo, nick, victor
Version: unspecified   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32311
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26107
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
23.05.00
Bug Depends on: 14435    
Bug Blocks:    
Attachments: Bug 17350: Purge old saved reports via cleanup_database
Bug 17350: Purge old saved reports via cleanup_database
Bug 17350: Add note about how the saved reports data is created in first place
Bug 17350: Purge old saved reports via cleanup_database
Bug 17350: Add note about how the saved reports data is created in first place

Description Katrin Fischer 2016-09-26 05:18:40 UTC
This is a follow-up bug to bug 14435 which reactivates an old feature that allows you to store the results of a run report in saved_reports.

Now that this will work again, there should also be an option to clean up the data stored - either from the script, the GUI or ideally from both.
Comment 1 AspenCat Team 2018-12-12 04:32:53 UTC
One should have the option to specify the number of results to keep (for example keep two on a report scheduled to run daily, as well as the option to delete saved results - perhaps with a "select all" when viewing saved results for a particular report.
Comment 2 Danielle Elder 2019-02-15 16:44:28 UTC
I do get requests from libraries to "clean this up". It does interfere with usability.
Comment 3 Andrew Fuerste-Henry 2022-11-18 18:09:02 UTC
+1 on this. It'd be good to have a way to delete these manually from the staff interface and also a way to set cleanup_database to do so.
Comment 4 Andrew Fuerste-Henry 2022-11-21 20:02:30 UTC
Created attachment 144116 [details] [review]
Bug 17350: Purge old saved reports via cleanup_database

To test:
apply patch
1 - have or create a report
2 - run your report via the command line with --store-results. Do this twice.
3 - update the saved_reports table to set date_run for one of your two saved results set to a datetime more than 5 days ago
4 - perl misc/cronjobs/cleanup_database.pl --reports 5 --verbose --confirm
5 - Koha tells you its deleting saved reports data from more than 5 days ago
6 - confirm in the database and the staff interface that it's done so
Comment 5 Andrew Fuerste-Henry 2022-11-21 20:08:52 UTC
I *think* I managed to write a patch to add this functionality to cleanup_databse. I've filed bug 32311 to add a way to delete these from the staff interface.
Comment 6 Katrin Fischer 2023-01-27 11:32:08 UTC
Created attachment 145721 [details] [review]
Bug 17350: Purge old saved reports via cleanup_database

To test:
apply patch
1 - have or create a report
2 - run your report via the command line with --store-results. Do this twice.
3 - update the saved_reports table to set date_run for one of your two saved results set to a datetime more than 5 days ago
4 - perl misc/cronjobs/cleanup_database.pl --reports 5 --verbose --confirm
5 - Koha tells you its deleting saved reports data from more than 5 days ago
6 - confirm in the database and the staff interface that it's done so

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 7 Katrin Fischer 2023-01-27 11:32:13 UTC
Created attachment 145722 [details] [review]
Bug 17350: Add note about how the saved reports data is created in first place

This amends the documentation of the cleanup_database.pl script
to include a hint for how the saved reports data is created.

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 8 Victor Grousset/tuxayo 2023-02-26 04:18:37 UTC
Created attachment 147414 [details] [review]
Bug 17350: Purge old saved reports via cleanup_database

To test:
apply patch
1 - have or create a report
2 - run your report via the command line with --store-results. Do this twice.
3 - update the saved_reports table to set date_run for one of your two saved results set to a datetime more than 5 days ago
4 - perl misc/cronjobs/cleanup_database.pl --reports 5 --verbose --confirm
5 - Koha tells you its deleting saved reports data from more than 5 days ago
6 - confirm in the database and the staff interface that it's done so

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Comment 9 Victor Grousset/tuxayo 2023-02-26 04:18:40 UTC
Created attachment 147415 [details] [review]
Bug 17350: Add note about how the saved reports data is created in first place

This amends the documentation of the cleanup_database.pl script
to include a hint for how the saved reports data is created.

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Comment 10 Victor Grousset/tuxayo 2023-02-26 04:19:06 UTC
Works, QA script happy, code looks good, passing QA :)
Comment 11 Tomás Cohen Arazi 2023-02-27 16:07:01 UTC
Pushed to master for 23.05.

Nice work everyone, thanks!