Koha-clms/misc
Nick Clemens c81d27de08
Bug 35948: Add jobs_unfinished_days and jobs_unfinished_type to cleanup_database.pl
This patch adds two new parameters to control the deletion of background jobs that did not complete.
Some libraries may want to keep a failed job longer than a completed one for debugging reasons.

To test:
0 - Apply patch
1 - Make some old failed jobs:
    INSERT INTO background_jobs (status,type,enqueued_on) VALUES
    ('started','update_elastic_index','2020-01-01'),
    ('failed','update_elastic_index','2026-01-01'),
    ('started','other_type','2021-01-01'),
    ('failed','other_type','2026-01-01');
2 - Confirm defaults of 365 and update_elastic_index for new params:
    perl misc/cronjobs/cleanup_database.pl -v --jobs-unfinished-days
3 - Should indicate 1 job older than 365 of type update_elastic_index would have been deleted
4 - Confirm days param works
    perl misc/cronjobs/cleanup_database.pl -v --jobs-unfinished-days 30
5 - Shoudl find 2 elastic jobs
6 - Confirm type param
    perl misc/cronjobs/cleanup_database.pl -v --jobs-unfinished-days --jobs-unfinished-type=other_type
7 - Should find 1
8 - Confirm type and days
    perl misc/cronjobs/cleanup_database.pl -v --jobs-unfinished-days 30 --jobs-unfinished-type=other_type
9 - Should find 2
10 - Confirm repeated type
     perl misc/cronjobs/cleanup_database.pl -v --jobs-unfinished-days=30 --jobs-unfinished-type=other_type --jobs-unfinished-type=update_elastic_index
11 - Finds 4
12 - Confirm deletion
     perl misc/cronjobs/cleanup_database.pl -v --jobs-unfinished-days=30 --jobs-unfinished-type=other_type --jobs-unfinished-type=update_elastic_index --confirm
13 - All your made up jobs are removed

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
2026-07-16 17:05:22 +00:00
..
admin Bug 40545: (follow-up) Correct GNU link 2025-10-15 16:12:02 -06:00
bin Bug 37538: Improve documentation for the OCLC import daemon script 2026-01-12 10:53:30 -07:00
cronjobs Bug 35948: Add jobs_unfinished_days and jobs_unfinished_type to cleanup_database.pl 2026-07-16 17:05:22 +00:00
devel Bug 38365: Add context to Koha::Devel::Files in add_csp_nonces.pl 2026-03-16 11:57:41 +01:00
interface_customization
…
maintenance Bug 41358: Apply consistent JSON logging to holds (Bug 40866) 2026-07-16 10:54:22 +00:00
migration_tools Bug 42764: Fix spelling errors across the codebase 2026-06-03 16:09:04 +00:00
release_notes 26.05.00: Add release notes 2026-05-26 14:16:10 -06:00
search_tools Bug 40722: Add a log when resetting mappings during elastic rebuild 2025-10-15 16:12:07 -06:00
translator Bug 41216: (QA follow-up): fix path of xt/author/tt_valid.t in comment 2026-04-10 09:48:11 -06:00
workers Bug 42669: Use exception type check for NoNodes and don't mask real failures 2026-07-16 10:54:40 +00:00
add_date_fields_to_marc_records.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
add_statistics_borrowers_categorycode.pl Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
batchCompareMARCvsFrameworks.pl Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
batchDeleteUnusedSubfields.pl Bug 39325: Automatic fix 2025-04-28 18:51:22 +02:00
batchImportMARCWithBiblionumbers.pl Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
batchRebuildBiblioTables.pl Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
batchRebuildItemsTables.pl Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
batchRepairMissingBiblionumbers.pl Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
batchdeletebiblios.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
check_sysprefs.pl Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
commit_file.pl Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
export_borrowers.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
export_records.pl Bug 41494: Rename "Koha administration" module name to "Administration" 2026-01-06 07:45:37 -07:00
import_patrons.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
koha-install-log
…
link_bibs_to_authorities.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
load_yaml.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
mod_zebraqueue.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
process_ill_updates.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
recreateIssueStatistics.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
sax_parser_print.pl Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
sax_parser_test.pl Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
sip_cli_emulator.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
stage_file.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
z3950_responder.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00