From 72767fb726c1c9da583302b1f6fa3bb0be877195 Mon Sep 17 00:00:00 2001
From: Nick Clemens <nick@bywatersolutions.com>
Date: Thu, 21 Jul 2022 12:44:40 +0000
Subject: [PATCH] Bug 31203: POC advance_notices

This patch proposes a new standard for cronlogaction

We copy @ARGV into a space separated string, then pass this to
cronlogaction

At the end of the script we add a call with info "COMPLETED"

To test:
1 - Apply patch
2 - perl misc/cronjobs/advance_notices.pl -v -m 4 -n -c
3 - sudo koha-mysql kohadev
4 - SELECT * FROM action_logs WHERE interface="CRON";
5 - Note start and completion logged
6 - Note command line arguments included in info

If this looks good I will copy this pattern to the other cronjobs

Signed-off-by: David Nind <david@davidnind.com>
---
 misc/cronjobs/advance_notices.pl | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/misc/cronjobs/advance_notices.pl b/misc/cronjobs/advance_notices.pl
index 9ec07659aa..615f98c3c6 100755
--- a/misc/cronjobs/advance_notices.pl
+++ b/misc/cronjobs/advance_notices.pl
@@ -185,6 +185,8 @@ my $itemscontent = join(',',qw( date_due title author barcode ));
 my $help    = 0;
 my $man     = 0;
 
+my $command_line_options = join(" ",@ARGV);
+
 GetOptions(
             'help|?'         => \$help,
             'man'            => \$man,
@@ -215,7 +217,7 @@ END_WARN
 unless ($confirm) {
      pod2usage(1);
 }
-cronlogaction();
+cronlogaction({ info => $command_line_options });
 
 my %branches = ();
 if (@branchcodes) {
@@ -635,6 +637,7 @@ sub send_digests {
     }
 }
 
+cronlogaction({ info => "COMPLETED" });
 
 1;
 
-- 
2.30.2