summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-04-30 12:47:28 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-04-30 12:47:28 (GMT)
commit3a09a75ce87c867c2f3efc1cf20ff1557cd0647d (patch)
tree9088f5e8399db278e36e6d1a00e4cafba8fa625a
parentf502cf1e7d2c433fb11fc47e6f106ef612d43c57 (diff)
add check if automation/show id exist when generating log
-rwxr-xr-xlib/RHRD/rddb.pm18
-rwxr-xr-xutils/rhrd-schedules11
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;
}