The help says: --bg-days DAYS Purge all finished background jobs this many days old. Defaults to 1 if no DAYS provide d. The script checks: 'bg-jobs:i' => \$background_days, We should use bg-days
Created attachment 143921 [details] [review] Bug 32093: Make help and code match for bg-days in cleanup_database.pl There as a mismatch between the parameter name in documentation (bg-days) and what was checked in the code (bg-jobs). This makes both match. To test: * Apply patch * Make sure you have some background_jobs older than one day * Verify the help of the script documents the parameter bg-days * Run the cleanup_database.pl job Example: ./misc/cronjobs/cleanup_database.pl --bg-days --confirm -v * Verify there are no errors and the lines have been deleted as expected
As this new option has not been released yet, we should push this before release so people can have it right from the beginning.
Created attachment 143930 [details] [review] Bug 32093: Make help and code match for bg-days in cleanup_database.pl There as a mismatch between the parameter name in documentation (bg-days) and what was checked in the code (bg-jobs). This makes both match. To test: * Apply patch * Make sure you have some background_jobs older than one day * Verify the help of the script documents the parameter bg-days * Run the cleanup_database.pl job Example: ./misc/cronjobs/cleanup_database.pl --bg-days --confirm -v * Verify there are no errors and the lines have been deleted as expected Signed-off-by: David Nind <david@davidnind.com>
Testing notes (using KTD): 1. To create some background jobs that could be purged (I'm sure there are quicker ways), I: - Enabled Elasticsearch (SearchEngine) - Reindexed (koha-elasticsearch --rebuild -d -b -a kohadev) - Edited some records (changed titles) - Updated the dates in the database for background jobs so that they are more than 1 day old (wasn't sure what date is used to trigger pruging): . select * from background_jobs; . update background_jobs set enqueued_on = "2022-11-13 20:09:00"; . update background_jobs set started_on = "2022-11-13 20:09:00"; . update background_jobs set ended_on = "2022-11-13 20:10:00"; - Edited a few more records (changed title) 2. Ran the cleanup_database.pl job. 3. Checked that the older background jobs were deleted in the database and UI.
Created attachment 144020 [details] [review] Bug 32093: Make help and code match for bg-days in cleanup_database.pl There as a mismatch between the parameter name in documentation (bg-days) and what was checked in the code (bg-jobs). This makes both match. To test: * Apply patch * Make sure you have some background_jobs older than one day * Verify the help of the script documents the parameter bg-days * Run the cleanup_database.pl job Example: ./misc/cronjobs/cleanup_database.pl --bg-days --confirm -v * Verify there are no errors and the lines have been deleted as expected Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Pushed to master for 22.11. Nice work everyone, thanks!