diff options
author | Christian Pointner <equinox@spreadspace.org> | 2015-07-24 18:27:32 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2015-07-24 18:27:32 (GMT) |
commit | b258601718869cab96ea99bbe7a7484f5a2aee75 (patch) | |
tree | bedb072800c45c0f5c665c0fd530796132a0ac50 | |
parent | 0ad0d912fbe96f8f57318bc00f44f564a4ce89a1 (diff) |
added function to load logs to rddb
-rwxr-xr-x | lib/RHRD/rddb.pm | 38 |
1 files changed, 38 insertions, 0 deletions
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; |