From 3a09a75ce87c867c2f3efc1cf20ff1557cd0647d Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sat, 30 Apr 2016 14:47:28 +0200 Subject: add check if automation/show id exist when generating log diff --git a/lib/RHRD/rddb.pm b/lib/RHRD/rddb.pm index a3c4f7a..df514d7 100755 --- a/lib/RHRD/rddb.pm +++ b/lib/RHRD/rddb.pm @@ -1105,6 +1105,24 @@ sub list_showids return @showids; } +sub check_show_exists +{ + my ($ctx, $showid) = @_; + + my $sql = qq{select count(*) from CART where NUMBER = ?}; + + my $sth = $ctx->{'dbh'}->prepare($sql) + or return (undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr); + + $sth->execute($showid) + or return (undef, 'ERROR', "Database Error: " . $sth->errstr); + + my ($result) = $sth->fetchrow_array(); + $sth->finish(); + + return ($result, 'OK', "successfully fetched show status"); +} + sub create_show_group { my ($ctx, $groupname) = @_; diff --git a/utils/rhrd-schedules b/utils/rhrd-schedules index b248e4d..7a83458 100755 --- a/utils/rhrd-schedules +++ b/utils/rhrd-schedules @@ -56,7 +56,16 @@ sub generate next if ($start->year != $year || $start->month != $month || $start->day != $day); if($showid < 0) { - print "WARNING: skipping entry whith invalid/unset automation id -> $start: $title ($pvid)\n"; + print "WARNING: skipping entry whith unset automation id -> $start: $title ($pvid)\n"; + next; + } + my ($exists, $status, $errorstring) = RHRD::rddb::check_show_exists($ctx, $showid); + unless(defined $exists) { + print "$status: $errorstring\n"; + return 1; + } + if($exists != 1) { + print "WARNING: skipping entry whith not existing automation id ($showid) -> $start: $title ($pvid)\n"; next; } -- cgit v0.10.2