diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-05-19 14:07:10 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-05-19 14:07:10 (GMT) |
commit | b4fe0e03eb1a712e379c2100ef92553afd4b26ed (patch) | |
tree | 3f858dd24a49059845328e8b0c4a9cad59297347 | |
parent | 10e2d89361988bd25a7085a34a874c8bf8ce98b5 (diff) |
fix edit show (change title didn't work)
-rwxr-xr-x | lib/RHRD/rddb.pm | 33 | ||||
-rwxr-xr-x | utils/rhrd-sanity-check | 18 | ||||
-rwxr-xr-x | utils/rhrd-show | 40 |
3 files changed, 59 insertions, 32 deletions
diff --git a/lib/RHRD/rddb.pm b/lib/RHRD/rddb.pm index 36a4298..a1ab7e6 100755 --- a/lib/RHRD/rddb.pm +++ b/lib/RHRD/rddb.pm @@ -1294,6 +1294,23 @@ sub get_show_title_and_log return ($title, $log, 'OK', 'success'); } +sub update_show_title +{ + my ($ctx, $showid, $title) = @_; + + my $sql = qq{update CART set TITLE = ? where NUMBER = ?;}; + + my $sth = $ctx->{'dbh'}->prepare($sql) + or return (undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr); + + my $cnt = $sth->execute($title, $showid) + or return (undef, 'ERROR', "Database Error: " . $sth->errstr); + + $sth->finish(); + + return ($cnt, 'OK', 'success'); +} + sub get_show_info { my ($ctx, $showid) = @_; @@ -1445,14 +1462,14 @@ sub get_next_free_showid $sth->execute($ctx->{'config'}{'specialgroups'}{'shows'}) or return (undef, 'ERROR', "Database Error: " . $sth->errstr); - my $show_id = $low; + my $showid = $low; while(my ($cart) = $sth->fetchrow_array()) { - last if($show_id < $cart); - $show_id += 1; + last if($showid < $cart); + $showid += 1; } $sth->finish(); - return ($show_id, 'OK', 'success'); + return ($showid, 'OK', 'success'); } sub create_show_macro_cart @@ -1477,7 +1494,7 @@ sub create_show_macro_cart sub create_show_dropbox { - my ($ctx, $groupname, $show_id, $rhythm, $dow, $starttime, $len) = @_; + my ($ctx, $groupname, $showid, $rhythm, $dow, $starttime, $len) = @_; my $param = join(';', ('S', $rhythm, $dow, $starttime, $len)); my $sql = qq{insert into DROPBOXES (STATION_NAME, GROUP_NAME, NORMALIZATION_LEVEL, AUTOTRIM_LEVEL, TO_CART, FIX_BROKEN_FORMATS, SET_USER_DEFINED) values (?, ?, ?, ?, ?, 'Y', ?)}; @@ -1485,7 +1502,7 @@ sub create_show_dropbox my $sth = $ctx->{'dbh'}->prepare($sql) or return (undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr); - my $cnt = $sth->execute($ctx->{'config'}{'dropboxes'}{'dropbox-pseudo-station'}, $groupname, $ctx->{'config'}{'dropboxes'}{'norm-level'}, $ctx->{'config'}{'dropboxes'}{'trim-level'}, $show_id, $param) + my $cnt = $sth->execute($ctx->{'config'}{'dropboxes'}{'dropbox-pseudo-station'}, $groupname, $ctx->{'config'}{'dropboxes'}{'norm-level'}, $ctx->{'config'}{'dropboxes'}{'trim-level'}, $showid, $param) or return (undef, 'ERROR', "Database Error: " . $sth->errstr); $sth->finish(); @@ -1495,7 +1512,7 @@ sub create_show_dropbox sub update_show_dropbox { - my ($ctx, $show_id, $rhythm, $dow, $starttime, $len) = @_; + my ($ctx, $showid, $rhythm, $dow, $starttime, $len) = @_; my $param = join(';', ('S', $rhythm, $dow, $starttime, $len)); my $sql = qq{update DROPBOXES set SET_USER_DEFINED = ? where TO_CART = ?}; @@ -1503,7 +1520,7 @@ sub update_show_dropbox my $sth = $ctx->{'dbh'}->prepare($sql) or return (undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr); - my $cnt = $sth->execute($param, $show_id) + my $cnt = $sth->execute($param, $showid) or return (undef, 'ERROR', "Database Error: " . $sth->errstr); $sth->finish(); diff --git a/utils/rhrd-sanity-check b/utils/rhrd-sanity-check index 74c1191..9507f6b 100755 --- a/utils/rhrd-sanity-check +++ b/utils/rhrd-sanity-check @@ -44,25 +44,25 @@ sub check_showids my $errors = 0, print "showids:\n"; - my @show_ids = RHRD::rddb::list_showids($ctx); - if(!defined $show_ids[0] && defined $show_ids[1]) { - print STDERR "$show_ids[1]: $show_ids[2]"; + my @showids = RHRD::rddb::list_showids($ctx); + if(!defined $showids[0] && defined $showids[1]) { + print STDERR "$showids[1]: $showids[2]"; return -1; } - for my $show_id (@show_ids) { - my @carts = RHRD::rddb::get_show_carts($ctx, $show_id); + for my $showid (@showids) { + my @carts = RHRD::rddb::get_show_carts($ctx, $showid); if(!defined $carts[0] && defined $carts[1]) { - print " showid '" . $show_id . "': $carts[2]\n"; + print " showid '" . $showid . "': $carts[2]\n"; $errors++; } if(scalar @carts == 0) { - print " showid '" . $show_id . "': log is empty\n"; + print " showid '" . $showid . "': log is empty\n"; $errors++; } - my ($group, $status, $errorstring) = RHRD::rddb::get_show_group($ctx, $show_id); + my ($group, $status, $errorstring) = RHRD::rddb::get_show_group($ctx, $showid); unless(defined($group)) { - print " showid '" . $show_id . "': has no dropbox assigned\n"; + print " showid '" . $showid . "': has no dropbox assigned\n"; $errors++; } else { } diff --git a/utils/rhrd-show b/utils/rhrd-show index 0c81c72..880ac5e 100755 --- a/utils/rhrd-show +++ b/utils/rhrd-show @@ -51,14 +51,14 @@ sub list sub show { - my ($ctx, $show_id) = @_; + my ($ctx, $showid) = @_; - my @carts = RHRD::rddb::get_show_carts($ctx, $show_id); + my @carts = RHRD::rddb::get_show_carts($ctx, $showid); if(!defined $carts[0] && defined $carts[1]) { print STDERR "$carts[1]: $carts[2]\n"; return 1; } - my ($show, $status, $errorstring) = RHRD::rddb::get_show_info($ctx, $show_id); + my ($show, $status, $errorstring) = RHRD::rddb::get_show_info($ctx, $showid); unless (defined $show) { print STDERR "$errorstring\n"; return 1; @@ -160,14 +160,14 @@ sub add } print " * created log with name: " . $name . "\n"; - (my $show_id, $status, $errorstring) = RHRD::rddb::create_show_macro_cart($ctx, $name, $title); + (my $showid, $status, $errorstring) = RHRD::rddb::create_show_macro_cart($ctx, $name, $title); unless(defined $result) { print STDERR $status . ": " . $errorstring . "\n"; return 1; } - print " * created macro cart -> new show-id = " . $show_id . "\n"; + print " * created macro cart -> new show-id = " . $showid . "\n"; - ($result, $status, $errorstring) = RHRD::rddb::create_show_dropbox($ctx, $groupname, $show_id, $rhythm, $dow, $starttime, $len); + ($result, $status, $errorstring) = RHRD::rddb::create_show_dropbox($ctx, $groupname, $showid, $rhythm, $dow, $starttime, $len); unless(defined $result) { print STDERR $status . ": " . $errorstring . "\n"; return 1; @@ -182,7 +182,7 @@ sub add sub edit__check_arguments { - my ($show_id, $title, $rhythm, $dow, $starttime, $len) = @_; + my ($showid, $title, $rhythm, $dow, $starttime, $len) = @_; my ($result, $err, $hint) = RHRD::utils::dropbox_param_rhythm_ok($rhythm); unless($result) { @@ -213,39 +213,49 @@ sub edit__check_arguments sub edit { - my ($ctx, $show_id, $title, $rhythm, $dow, $starttime, $len) = @_; + my ($ctx, $showid, $title, $rhythm, $dow, $starttime, $len) = @_; - my $ret = edit__check_arguments($show_id, $title, $rhythm, $dow, $starttime, $len); + my $ret = edit__check_arguments($showid, $title, $rhythm, $dow, $starttime, $len); if($ret) { return $ret; } ($dow, undef, undef) = RHRD::utils::cmdline_dow($dow); - my ($result, $status, $errorstring) = RHRD::rddb::update_show_dropbox($ctx, $show_id, $rhythm, $dow, $starttime, $len); + my ($result, $status, $errorstring) = RHRD::rddb::update_show_title($ctx, $showid, $title); unless(defined $result) { print STDERR $status . ": " . $errorstring . "\n"; return 1; } if ($result != 1) { - print "show '" . $show_id ."' does not exist.\n"; + print "show '" . $showid ."' does not exist.\n"; return 1; } - print "show '" . $show_id . "' successfully changed!\n"; + ($result, $status, $errorstring) = RHRD::rddb::update_show_dropbox($ctx, $showid, $rhythm, $dow, $starttime, $len); + unless(defined $result) { + print STDERR $status . ": " . $errorstring . "\n"; + return 1; + } + if ($result != 1) { + print "show '" . $showid ."' does not exist.\n"; + return 1; + } + + print "show '" . $showid . "' successfully changed!\n"; return 0; } sub remove { - my ($ctx, $show_id) = @_; + my ($ctx, $showid) = @_; - my ($group, $status, $errorstring) = RHRD::rddb::get_show_group($ctx, $show_id); + my ($group, $status, $errorstring) = RHRD::rddb::get_show_group($ctx, $showid); unless(defined $group) { print STDERR $status . ": " . $errorstring . "\n"; return 1; } - my @results = RHRD::rddb::remove_show($ctx, $show_id); + my @results = RHRD::rddb::remove_show($ctx, $showid); if(!defined $results[0] && defined $results[2]) { print STDERR $results[1] . ": " . $results[2] . "\n"; return 1; |