diff options
author | Christian Pointner <equinox@spreadspace.org> | 2015-09-30 22:16:45 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2015-09-30 22:16:45 (GMT) |
commit | 88ba274e7841fedffe9ef98b0933c0610ac6997c (patch) | |
tree | 749f384c7f2be59ec3c6d8159916d3377fadf5f8 /utils/rd-show | |
parent | 3e52b13a26edcf217969f6f52b716486ed61dabd (diff) |
minor refactoring
Diffstat (limited to 'utils/rd-show')
-rwxr-xr-x | utils/rd-show | 69 |
1 files changed, 40 insertions, 29 deletions
diff --git a/utils/rd-show b/utils/rd-show index 7a2736c..17286e9 100755 --- a/utils/rd-show +++ b/utils/rd-show @@ -73,6 +73,45 @@ sub show return 0; } + + +sub add__create_group +{ + my ($dbh, $groupname) = @_; + + print " > '" . $groupname . "' does not exist - creating it .. "; + my ($cnt, $status, $errorstring) = RHRD::rddb::add_group($dbh, $groupname); + unless(defined $cnt) { + 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($dbh); + 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_carts($dbh, $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($dbh, $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__get_group_carts { my ($dbh, $groupname, $num_carts) = @_; @@ -90,35 +129,7 @@ sub add__get_group_carts # find free range in group which is big enough for $num_carts carts } else { - print " > '" . $groupname . "' does not exist - creating it .. "; - (my $cnt, $status, $errorstring) = RHRD::rddb::add_group($dbh, $groupname); - unless(defined $cnt) { - print STDERR $status . ": " . $errorstring . "\n"; - return undef; - } - print int($cnt) . " rows affected\n"; - - ($low_cart, my $high_cart, $errorstring) = RHRD::rddb::get_shows_next_free_slot($dbh); - 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_carts($dbh, $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($dbh, $groupname, 'Y', 'Y', 'Y'); - unless(defined $cnt) { - print STDERR $status . ": " . $errorstring . "\n"; - return undef; - } - print int($cnt) . " rows affected\n"; + $low_cart = add__create_group($dbh, $groupname); } return $low_cart; |