diff options
author | Christian Pointner <equinox@spreadspace.org> | 2016-02-10 04:08:33 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2016-02-10 04:08:33 (GMT) |
commit | c1d4230a6699ea9b41855a7f233ff1bd546d2949 (patch) | |
tree | 5ca2cd37369c43cd796a58a649363343ab171d22 /lib | |
parent | 853ff92d697e430d3de9e00100dd0e549a0f050e (diff) |
updated to new library version
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/RHRD/rddb.pm | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/lib/RHRD/rddb.pm b/lib/RHRD/rddb.pm index 1be87ac..64837da 100755 --- a/lib/RHRD/rddb.pm +++ b/lib/RHRD/rddb.pm @@ -30,7 +30,7 @@ use RHRD::utils; ########################### constants ########################### use constant { - DB_VERSION => 245, + DB_VERSION => 250, RD_CONFIG_FILE => '/etc/rd.conf', RD_INVALID_CART => 0, RD_MIN_CART => 1, @@ -1473,26 +1473,20 @@ sub get_musicpools_clocks { my ($ctx) = @_; - my @reqs; - for my $day (0 .. 6){ - for my $hour (0 .. 23){ - my $dow = $day + 1; - $dow = 0 if $dow >=7; - push @reqs, 'select ' . $dow . ' as DOW ,' . $hour . ' as HOUR,CLOCK' . (($day*24) + $hour) . - ' as CLOCK from SERVICES where NAME=' . $ctx->{'dbh'}->quote($ctx->{'config'}{'shows'}{'service'}); - } - } - - my $sql = 'select GRID.DOW,GRID.HOUR,CLOCKS.SHORT_NAME,CLOCKS.COLOR,GROUPS.DESCRIPTION from DROPBOXES,GROUPS,CLOCKS,(' . join(' UNION ' , @reqs) . ") as GRID where GRID.CLOCK = CLOCKS.NAME and CLOCKS.SHORT_NAME = DROPBOXES.PATH and DROPBOXES.GROUP_NAME = GROUPS.NAME;"; + my $sql = 'select SVC_CLOCKS.HOUR,CLOCKS.SHORT_NAME,CLOCKS.COLOR,GROUPS.DESCRIPTION from DROPBOXES,GROUPS,CLOCKS,SVC_CLOCKS where SVC_CLOCKS.SERVICE_NAME = ? and SVC_CLOCKS.CLOCK_NAME = CLOCKS.NAME and CLOCKS.SHORT_NAME = DROPBOXES.PATH and DROPBOXES.GROUP_NAME = GROUPS.NAME order by SVC_CLOCKS.HOUR;'; my $sth = $ctx->{'dbh'}->prepare($sql) or return (undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr); - my $cnt = $sth->execute() + my $cnt = $sth->execute($ctx->{'config'}{'shows'}{'service'}) or return (undef, 'ERROR', "Database Error: " . $sth->errstr); my @clocks; - while(my ($dow, $hour, $shortname, $color, $title) = $sth->fetchrow_array()) { + while(my ($idx, $shortname, $color, $title) = $sth->fetchrow_array()) { + my $dow = int($idx / 24) + 1; + $dow = 0 if $dow > 6; + my $hour = $idx % 24; + my $clock = {}; $clock->{'DOW'} = $dow; $clock->{'HOUR'} = $hour; @@ -1529,12 +1523,15 @@ sub set_musicpools_clock my $day = $dow - 1; $day = 6 if $dow == 0; my $idx = (($day*24) + $hour); - $sql = 'update SERVICES set CLOCK' . $idx . ' = ? where NAME = ?'; + $sql = 'update SVC_CLOCKS set CLOCK_NAME = ? where SERVICE_NAME = ? and HOUR = ?'; - my $rows = $ctx->{'dbh'}->do($sql, undef, $name, $ctx->{'config'}{'shows'}{'service'}) + $sth = $ctx->{'dbh'}->prepare($sql) or return (undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr); - unless($rows == 1) { + my $cnt = $sth->execute($name, $ctx->{'config'}{'shows'}{'service'}, $idx) + or return (undef, 'ERROR', "Database Error: " . $sth->errstr); + + unless($cnt == 1) { return (undef, 'ERROR', "clock does not exist") } return (1, 'OK', 'success'); |