summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2013-02-11 13:18:59 -0800
committerIvan Kohler <ivan@freeside.biz>2013-02-11 13:18:59 -0800
commit130b7fb03bc8fcc6c6a1b29b36f65d53333ec05a (patch)
treea45615a0f9d0d9763433922a70749d28d2042e87
parentfb33bc6850eb5ebf1f63d79afd503202b277b9a3 (diff)
fix RADIUS open sessions report (modern mysql & Pg?), RT#14218
-rw-r--r--FS/FS/part_export/sqlradius.pm32
1 files changed, 20 insertions, 12 deletions
diff --git a/FS/FS/part_export/sqlradius.pm b/FS/FS/part_export/sqlradius.pm
index 58cc5be95..18ee30488 100644
--- a/FS/FS/part_export/sqlradius.pm
+++ b/FS/FS/part_export/sqlradius.pm
@@ -727,17 +727,21 @@ sub usage_sessions {
push @where, " CalledStationID LIKE 'sip:$prefix\%'";
}
- if ( $start ) {
- push @where, "$str2time AcctStopTime ) >= ?";
- push @param, $start;
- }
- if ( $end ) {
- push @where, "$str2time AcctStopTime ) <= ?";
- push @param, $end;
- }
if ( $opt->{open_sessions} ) {
push @where, 'AcctStopTime IS NULL';
+ } else {
+
+ if ( $start ) {
+ push @where, "$str2time AcctStopTime ) >= ?";
+ push @param, $start;
+ }
+ if ( $end ) {
+ push @where, "$str2time AcctStopTime ) <= ?";
+ push @param, $end;
+ }
+
}
+
if ( $opt->{starttime_start} ) {
push @where, "$str2time AcctStartTime ) >= ?";
push @param, $opt->{starttime_start};
@@ -756,10 +760,14 @@ sub usage_sessions {
my $orderby = 'ORDER BY AcctStartTime DESC';
$orderby = '' if $summarize;
- my $sth = $dbh->prepare('SELECT '. join(', ', @fields).
- " FROM radacct $where $groupby $orderby
- ") or die $dbh->errstr;
- $sth->execute(@param) or die $sth->errstr;
+ my $sql = 'SELECT '. join(', ', @fields).
+ " FROM radacct $where $groupby $orderby";
+ if ( $DEBUG ) {
+ warn $sql;
+ warn join(',', @param);
+ }
+ my $sth = $dbh->prepare($sql) or die $dbh->errstr;
+ $sth->execute(@param) or die $sth->errstr;
[ map { { %$_ } } @{ $sth->fetchall_arrayref({}) } ];