diff options
Diffstat (limited to 'utils/rhrd-show')
-rwxr-xr-x | utils/rhrd-show | 73 |
1 files changed, 16 insertions, 57 deletions
diff --git a/utils/rhrd-show b/utils/rhrd-show index 6f3bc7d..3431450 100755 --- a/utils/rhrd-show +++ b/utils/rhrd-show @@ -114,81 +114,40 @@ sub add__check_arguments return 0; } -sub add__get_show_carts +sub add { - my ($ctx, $groupname, $num_carts) = @_; + my ($ctx, $groupname, $name, $title, $num_carts, $rhythm, $dow, $starttime, $len) = @_; + + my $ret = add__check_arguments($name, $title, $num_carts, $rhythm, $dow, $starttime, $len); + if($ret) { + return $ret; + } + + print " * creating show: " . $title . " (" . $name . ") for group '" . $groupname . "'\n"; my ($result, $status, $errorstring) = RHRD::rddb::check_group($ctx, $groupname); unless(defined $result) { print STDERR $status . ": " . $errorstring . "\n"; - return undef; + return 1; } my $low_cart = 0; if($result) { - print " > using existing group '" . $groupname . "'\n"; + print " * using existing group '" . $groupname . "'\n"; ($low_cart, $status, $errorstring) = RHRD::rddb::get_next_free_show_group_carts($ctx, $groupname, $num_carts); } else { - print " > '" . $groupname . "' does not exist - creating it .. "; - $low_cart = add__create_group($ctx, $groupname); + print " * '" . $groupname . "' does not exist - creating it\n"; + ($low_cart, $status, $errorstring) = RHRD::rddb::create_show_group($ctx, $groupname); } - - return $low_cart; -} - -sub add__create_group -{ - my ($ctx, $groupname) = @_; - - my ($cnt, $status, $errorstring) = RHRD::rddb::add_group($ctx, $groupname); - unless(defined $cnt) { + unless(defined $low_cart) { print STDERR $status . ": " . $errorstring . "\n"; - return undef; - } - print int($cnt) . " rows affected\n"; - - (my $low_cart, my $high_cart, $errorstring) = RHRD::rddb::get_shows_next_free_slot($ctx); - if(!$low_cart) { - print $high_cart . ": " . $errorstring . "\n"; - return undef; - } - print " using carts " . $low_cart . " - " . $high_cart . " for new group .. "; - - ($cnt, $status, $errorstring) = RHRD::rddb::set_group_cart_range($ctx, $groupname, $low_cart, $high_cart, 1, 'Y'); - unless(defined $cnt) { - print STDERR $status . ": " . $errorstring . "\n"; - return undef; - } - print int($cnt) . " rows affected\n"; - - print " enabling reports .. "; - ($cnt, $status, $errorstring) = RHRD::rddb::set_group_reports($ctx, $groupname, 'Y', 'Y', 'Y'); - unless(defined $cnt) { - print STDERR $status . ": " . $errorstring . "\n"; - return undef; - } - print int($cnt) . " rows affected\n"; - - return $low_cart; -} - -sub add -{ - my ($ctx, $groupname, $name, $title, $num_carts, $rhythm, $dow, $starttime, $len) = @_; - - my $ret = add__check_arguments($name, $title, $num_carts, $rhythm, $dow, $starttime, $len); - if($ret) { - return $ret; + return 1; } - print " * creating show: " . $title . " (" . $name . ") for group '" . $groupname . "'\n"; - - my $low_cart = add__get_show_carts($ctx, $groupname, $num_carts); - return 1 unless defined($low_cart); my $high_cart = $low_cart + $num_carts - 1; print " * will be using carts: " . $low_cart . " - " . $high_cart . "\n"; - my ($result, $status, $errorstring) = RHRD::rddb::create_show_log($ctx, $name, $low_cart, $high_cart); + ($result, $status, $errorstring) = RHRD::rddb::create_show_log($ctx, $name, $low_cart, $high_cart); unless(defined $result) { print STDERR $status . ": " . $errorstring . "\n"; return 1; |