summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-07-31 12:43:47 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-07-31 12:43:47 (GMT)
commitaf294a1f65fd66f0a0ecf59e199785703d1b947e (patch)
tree50014968aca2abafee7987e18eb694a23d554094
parent1283d78ec24c3b4e084409610e4711015044ce58 (diff)
print clock usage for musicpool
-rwxr-xr-xlib/RHRD/rddb.pm81
-rwxr-xr-xutils/rhrd-pool20
2 files changed, 75 insertions, 26 deletions
diff --git a/lib/RHRD/rddb.pm b/lib/RHRD/rddb.pm
index de34bbd..5141ff5 100755
--- a/lib/RHRD/rddb.pm
+++ b/lib/RHRD/rddb.pm
@@ -2119,6 +2119,32 @@ sub create_musicpool_group
return ($num, 'OK', 'success');
}
+sub get_musicpool_carts_used
+{
+ my ($ctx, $shortname) = @_;
+
+ my ($groupname, $status, $errorstring) = get_musicpool_group($ctx, $shortname);
+ unless (defined $groupname) {
+ return (undef, $status, $errorstring);
+ }
+
+ my $sql = qq{select NUMBER from CART where GROUP_NAME = ? order by NUMBER};
+
+ my $sth = $ctx->{'dbh'}->prepare($sql)
+ or return (undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr);
+
+ $sth->execute($groupname)
+ or return (undef, 'ERROR', "Database Error: " . $sth->errstr);
+
+ my @carts;
+ while(my ($cart) = $sth->fetchrow_array()) {
+ push @carts, $cart;
+ }
+ $sth->finish();
+
+ return @carts;
+}
+
sub create_musicpool_event
{
my ($ctx, $shortname, $groupname, $color) = @_;
@@ -2187,6 +2213,35 @@ sub create_musicpool_clock
return (1, 'OK', 'success');
}
+sub get_musicpool_clock_usage
+{
+ my ($ctx, $shortname) = @_;
+
+ my $sql = 'select HOUR from SVC_CLOCKS where CLOCK_NAME = ? order by HOUR;';
+
+ my $sth = $ctx->{'dbh'}->prepare($sql)
+ or return (undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr);
+
+ my $cnt = $sth->execute($shortname)
+ or return (undef, 'ERROR', "Database Error: " . $sth->errstr);
+
+ my @slots;
+ while(my ($idx) = $sth->fetchrow_array()) {
+ my $dow = int($idx / 24) + 1;
+ $dow = 0 if $dow > 6;
+ my $hour = $idx % 24;
+
+ my $slot = {};
+ $slot->{'DOW'} = $dow;
+ $slot->{'HOUR'} = $hour;
+ push @slots, $slot;
+ }
+
+ $sth->finish();
+
+ return @slots;
+}
+
sub create_musicpool_dropbox
{
my ($ctx, $groupname, $shortname) = @_;
@@ -2284,32 +2339,6 @@ sub remove_musicpool
return @actions;
}
-sub get_musicpool_carts_used
-{
- my ($ctx, $shortname) = @_;
-
- my ($groupname, $status, $errorstring) = get_musicpool_group($ctx, $shortname);
- unless (defined $groupname) {
- return (undef, $status, $errorstring);
- }
-
- my $sql = qq{select NUMBER from CART where GROUP_NAME = ? order by NUMBER};
-
- my $sth = $ctx->{'dbh'}->prepare($sql)
- or return (undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr);
-
- $sth->execute($groupname)
- or return (undef, 'ERROR', "Database Error: " . $sth->errstr);
-
- my @carts;
- while(my ($cart) = $sth->fetchrow_array()) {
- push @carts, $cart;
- }
- $sth->finish();
-
- return @carts;
-}
-
sub is_musicgrid_user
{
my ($ctx, $username) = @_;
diff --git a/utils/rhrd-pool b/utils/rhrd-pool
index dc85f94..93e943c 100755
--- a/utils/rhrd-pool
+++ b/utils/rhrd-pool
@@ -64,8 +64,28 @@ sub show
return 1;
}
+ my @slots = RHRD::rddb::get_musicpool_clock_usage($ctx, $shortname);
+ if(!defined $slots[0] && defined $slots[1]) {
+ print STDERR "$slots[1]: $slots[2]";
+ return 1;
+ }
+
print $pool->{'TITLE'} . " (" . $pool->{'SHORTNAME'} . "):\n";
print " group: " . $pool->{'GROUP'} . ", carts: " . $pool->{'LOW_CART'} . "-" . $pool->{'HIGH_CART'} . " (" . scalar(@carts) . " used)\n";
+ print " clock usage:";
+ my $current_dow = -1;
+ my $first = 0;
+ for my $slot (@slots) {
+ if($slot->{'DOW'} != $current_dow) {
+ $current_dow = $slot->{'DOW'};
+ print "\n " . Date::Calc::Day_of_Week_to_Text(($slot->{'DOW'} == 0) ? 7 : $slot->{'DOW'}) . ":\t";
+ $first = 1;
+ }
+ print ", " unless($first);
+ $first = 0;
+ print sprintf("%02d:00", $slot->{'HOUR'})
+ }
+ print "\n";
return 0;
}