From b258601718869cab96ea99bbe7a7484f5a2aee75 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Fri, 24 Jul 2015 20:27:32 +0200 Subject: added function to load logs to rddb diff --git a/lib/RHRD/rddb.pm b/lib/RHRD/rddb.pm index 0074833..b1641ed 100755 --- a/lib/RHRD/rddb.pm +++ b/lib/RHRD/rddb.pm @@ -181,5 +181,43 @@ sub get_dropboxes return @allowed_dbs; } +sub get_show_carts +{ + my ($dbh, $logname, $group_low_cart, $group_high_cart) = @_; + + my $sql = qq{select LOG_EXISTS from LOGS where NAME = ?;}; + my $sth = $dbh->prepare($sql) + or return (undef, 'ERROR', "Database Error: " . $dbh->errstr); + + $sth->execute($logname) + or return (undef, 'ERROR', "Database Error: " . $sth->errstr); + + my $log_exists = $sth->fetchrow_array; + $sth->finish(); + + if(!defined $log_exists && $log_exists eq 'Y') { + return (undef, 'ERROR', "Log with name '$logname' does not exist") + } + + $logname=~s/ /_/g; + $logname = $dbh->quote_identifier($logname . '_LOG'); + $sql = qq{select COUNT,CART_NUMBER from $logname order by COUNT;}; + + $sth = $dbh->prepare($sql) + or return (undef, 'ERROR', "Database Error: " . $dbh->errstr); + + $sth->execute() + or return (undef, 'ERROR', "Database Error: " . $sth->errstr); + + my @carts; + while(my ($count, $cart) = $sth->fetchrow_array()) { + if($cart >= $group_low_cart && $cart <= $group_high_cart) { + push @carts, $cart; + } + } + $sth->finish(); + + return @carts; +} return 1; -- cgit v0.10.2