diff options
-rwxr-xr-x | lib/RHRD/rddb.pm | 18 | ||||
-rwxr-xr-x | utils/rhrd-schedules | 11 |
2 files changed, 28 insertions, 1 deletions
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; } |