From 543454f7655200f12311dd26e824c011cd234813 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 19 May 2022 13:50:59 +0000 Subject: [PATCH] Bug 28950: Mark serial late when past grace period MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This script had some oddities: - There was a LEFT JOIN to subscription, but no error printed if no subscription I changed this to a JOIN as there is a constraint, so this shoudl not happen - Publisheddate was checked after the SQL, moved into query - We checked for the next issue, and marked late only if that issue was already expected This overruled grace period, which should be the mnarker for a serial being late The grace period should be extended if you wish to wait for next issue - If no next published date, we reported an error on the planneddate - Script without confirm had no reporting Signed-off-by: Joonas Kylmälä Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi --- misc/cronjobs/serialsUpdate.pl | 43 +++++++--------------------------- 1 file changed, 9 insertions(+), 34 deletions(-) diff --git a/misc/cronjobs/serialsUpdate.pl b/misc/cronjobs/serialsUpdate.pl index 0b8a2acb2d..b6166ee3a8 100755 --- a/misc/cronjobs/serialsUpdate.pl +++ b/misc/cronjobs/serialsUpdate.pl @@ -95,7 +95,7 @@ my $sth = $dbh->prepare( serial.publisheddate, subscription.subscriptionid FROM serial - LEFT JOIN subscription + JOIN subscription ON (subscription.subscriptionid=serial.subscriptionid) LEFT JOIN subscription_frequencies ON (subscription.periodicity = subscription_frequencies.id) @@ -103,44 +103,19 @@ my $sth = $dbh->prepare( AND subscription_frequencies.unit IS NOT NULL AND DATE_ADD(planneddate, INTERVAL CAST(graceperiod AS SIGNED) DAY) < NOW() AND subscription.closed = 0 + AND publisheddate IS NOT NULL } ); $sth->execute(); while ( my $issue = $sth->fetchrow_hashref ) { - - my $subscription = &GetSubscription( $issue->{subscriptionid} ); - my $publisheddate = $issue->{publisheddate}; - - if ( $subscription && $publisheddate ) { - my $freqdata = GetSubscriptionFrequency($subscription->{'periodicity'}); - my $nextpublisheddate = GetNextDate( $subscription, $publisheddate, $freqdata ); - my $today = dt_from_string->ymd; - - if ( $nextpublisheddate && $today ) { - my ( $year, $month, $day ) = split( /-/, $nextpublisheddate ); - my ( $tyear, $tmonth, $tday ) = split( /-/, $today ); - if ( check_date( $year, $month, $day ) - && check_date( $tyear, $tmonth, $tday ) - && Date_to_Days( $year, $month, $day ) < - Date_to_Days( $tyear, $tmonth, $tday ) ) - { - $confirm - and ModSerialStatus( $issue->{serialid}, $issue->{serialseq}, - $issue->{planneddate}, $issue->{publisheddate}, $issue->{publisheddatetext}, - 3, $note ); - $verbose - and print "Serial issue with id=" . $issue->{serialid} . " updated\n"; - } - } - else { - $verbose - and print "Error with serial(" - . $issue->{serialid} - . ") has no existent subscription(" - . $issue->{subscriptionid} - . ") attached or planneddate is wrong\n"; - } + if ( $confirm ){ + ModSerialStatus( $issue->{serialid}, $issue->{serialseq}, + $issue->{planneddate}, $issue->{publisheddate}, $issue->{publisheddatetext}, + 3, $note ); + $verbose and print "Serial issue with id=" . $issue->{serialid} . " marked late\n"; + } else { + print "Serial issue with id=" . $issue->{serialid} . " would have been marked late\n"; } } -- 2.39.5