summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README50
-rwxr-xr-xlib/RHRD/rddb.pm48
-rwxr-xr-xtest/get-range52
-rwxr-xr-xutils/rd-group2
4 files changed, 148 insertions, 4 deletions
diff --git a/README b/README
new file mode 100644
index 0000000..e64f3e6
--- /dev/null
+++ b/README
@@ -0,0 +1,50 @@
+Introduction
+============
+
+tba...
+
+
+CART RANGES:
+============
+
+ 0 --+----------+
+ | 2000 | System Macros
+ 2000 --+----------+
+ | 1000 | Jingles
+ 3000 --+----------+
+ | |
+ | 7000 | <unused>
+ | |
+ 10000 --+----------+
+ | |
+ | 10000 | Show Macros
+ | |
+ 20000 --+----------+
+ | |
+ | |
+ | 80000 | <unused>
+ | |
+ | |
+ 100000 --+----------+
+ | |
+ | |
+ | |
+ | 400000 | Show Groups (200 Carts each)
+ | |
+ | |
+ | |
+ 500000 --+----------+
+ | |
+ | |
+ | |
+ | 400000 | <unused>
+ | |
+ | |
+ | |
+ 800000 --+----------+
+ | |
+ | |
+ | 200000 | Music Pools (1000 Carts each)
+ | |
+ | |
+ 999999 --+----------+
diff --git a/lib/RHRD/rddb.pm b/lib/RHRD/rddb.pm
index 36b9dc0..6e83a5e 100755
--- a/lib/RHRD/rddb.pm
+++ b/lib/RHRD/rddb.pm
@@ -32,6 +32,15 @@ use constant {
DB_VERSION => 245,
RD_CONFIG_FILE => '/etc/rd.conf',
DROPBOX_PSEUDO_STATION_NAME => 'import-dropbox',
+ RD_MIN_CART => 1,
+ RD_MAX_CART => 999999,
+ RD_MIN_CUT => 1,
+ RD_MAX_CUT => 999,
+
+ RHRD_SYSTEM_MACROS_GROUP => 'SYSTEM',
+ RHRD_SHOW_MACROS_GROUP => 'SHOWS',
+ RHRD_ALLSHOWS_GROUP => 'ALL_SHOWS',
+ RHRD_ALLMUSICPOOLS_GROUP => 'ALL_POOLS',
};
########################### connection handling ###########################
@@ -77,6 +86,27 @@ sub closedb
$dbh->disconnect();
}
+########################### utils ###########################
+
+sub get_cart_range
+{
+ my ($dbh, $groupname) = @_;
+
+ my $sql = qq{select DEFAULT_LOW_CART, DEFAULT_HIGH_CART, DEFAULT_TITLE from GROUPS where NAME = ?;};
+ my $sth = $dbh->prepare($sql)
+ or return (undef, 'ERROR', "Database Error: " . $dbh->errstr);
+
+ $sth->execute($groupname)
+ or return (undef, 'ERROR', "Database Error: " . $sth->errstr);
+
+ my ($low_cart, $high_cart, $chunk_size) = $sth->fetchrow_array;
+ $sth->finish();
+
+ unless(defined $low_cart) { return (undef, 'ERROR', "group '" . $groupname . "' does not exist"); }
+
+ return ($low_cart, $high_cart, $chunk_size);
+}
+
########################### TOKEN handling ###########################
sub get_token
@@ -415,8 +445,6 @@ sub set_group_carts
$enforce_cart_range = 'N';
}
- # TODO: check if cart range is already in use by other group
-
my $sql = qq{update GROUPS set DEFAULT_LOW_CART = ?, DEFAULT_HIGH_CART = ?, DEFAULT_CART_TYPE = ? , ENFORCE_CART_RANGE = ? where NAME = ?;};
my $sth = $dbh->prepare($sql)
or return (undef, 'ERROR', "Database Error: " . $dbh->errstr);
@@ -600,3 +628,19 @@ sub get_show_carts
}
return 1;
+
+sub get_shows_cart_range
+{
+ my ($dbh) = @_;
+ return get_cart_range($dbh, RHRD_ALLSHOWS_GROUP)
+}
+
+########################### MUSICPOOL handling ###########################
+
+sub get_musicpool_cart_range
+{
+ my ($dbh) = @_;
+ return get_cart_range($dbh, RHRD_ALLMUSICPOOLS_GROUP)
+}
+
+################################# END ####################################
diff --git a/test/get-range b/test/get-range
new file mode 100755
index 0000000..13e5533
--- /dev/null
+++ b/test/get-range
@@ -0,0 +1,52 @@
+#!/usr/bin/perl -w
+#
+# rhrdlibs
+#
+# Copyright (C) 2015 Christian Pointner <equinox@helsinki.at>
+#
+# This file is part of rhrdlibs.
+#
+# rhrdlibs is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# any later version.
+#
+# rhrdlibs is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with rhrdlibs. If not, see <http://www.gnu.org/licenses/>.
+#
+
+use strict;
+use lib "../lib/";
+
+use RHRD::rddb;
+
+my ($dbh, undef, $errorstring) = RHRD::rddb::opendb();
+if(defined $dbh) {
+ print "Shows:\n";
+ my ($low_cart, $high_cart, $chunk_size) = RHRD::rddb::get_shows_cart_range($dbh);
+ if(!$low_cart) {
+ print "$high_cart: $chunk_size\n";
+ } else {
+ print "Range: " . $low_cart . " - " . $high_cart . ", chunk size: " . $chunk_size . "\n";
+ }
+
+ print "\nMusic Pools:\n";
+ ($low_cart, $high_cart, $chunk_size) = RHRD::rddb::get_musicpool_cart_range($dbh);
+ if(!$low_cart) {
+ print "$high_cart: $chunk_size\n";
+ } else {
+ print "Range: " . $low_cart . " - " . $high_cart . ", chunk size: " . $chunk_size . "\n";
+ }
+
+ RHRD::rddb::closedb($dbh);
+} else {
+ print STDERR "$errorstring\n";
+ exit 1;
+}
+
+exit 0
diff --git a/utils/rd-group b/utils/rd-group
index da50be6..a221d9f 100755
--- a/utils/rd-group
+++ b/utils/rd-group
@@ -21,8 +21,6 @@
#
use strict;
-use lib "../lib/";
-
use RHRD::rddb;
my $num_args = $#ARGV + 1;