summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2015-10-07 02:11:40 (GMT)
committerChristian Pointner <equinox@spreadspace.org>2015-10-07 02:11:40 (GMT)
commitb040a840eb34d2d5e80fe19ed19a1a8125ca549d (patch)
tree5a0593fdbc5209f4c376c1a98a5edf000dbaf5d9
parenta67de4921bd05a567e5957729f1e2d06358d1218 (diff)
most of add show command is now in rddb
-rwxr-xr-xlib/RHRD/rddb.pm27
-rwxr-xr-xutils/rhrd-show73
2 files changed, 43 insertions, 57 deletions
diff --git a/lib/RHRD/rddb.pm b/lib/RHRD/rddb.pm
index 14c21a1..f60b78f 100755
--- a/lib/RHRD/rddb.pm
+++ b/lib/RHRD/rddb.pm
@@ -938,6 +938,33 @@ sub list_shows
return @show_dbs;
}
+sub create_show_group
+{
+ my ($ctx, $groupname) = @_;
+
+ my ($cnt, $status, $errorstring) = add_group($ctx, $groupname);
+ unless(defined $cnt) {
+ return (undef, $status, $errorstring);
+ }
+
+ (my $low_cart, my $high_cart, $errorstring) = get_shows_next_free_slot($ctx);
+ if(!$low_cart) {
+ return (undef, $high_cart, $errorstring);
+ }
+
+ ($cnt, $status, $errorstring) = set_group_cart_range($ctx, $groupname, $low_cart, $high_cart, 1, 'Y');
+ unless(defined $cnt) {
+ return (undef, $status, $errorstring);
+ }
+
+ ($cnt, $status, $errorstring) = RHRD::rddb::set_group_reports($ctx, $groupname, 'Y', 'Y', 'Y');
+ unless(defined $cnt) {
+ return (undef, $status, $errorstring);
+ }
+
+ return ($low_cart, 'OK', 'success');
+}
+
sub get_show_group_cart_range
{
my ($ctx, $showid) = @_;
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;