[freeside-commits] freeside/FS/FS/part_export sqlradius.pm, 1.46, 1.46.2.1

Erik Levinson levinse at wavetail.420.am
Wed May 11 08:23:58 PDT 2011


Update of /home/cvs/cvsroot/freeside/FS/FS/part_export
In directory wavetail.420.am:/tmp/cvs-serv17074/FS/FS/part_export

Modified Files:
      Tag: FREESIDE_2_1_BRANCH
	sqlradius.pm 
Log Message:
add summarized RADIUS report feature, RT11776

Index: sqlradius.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_export/sqlradius.pm,v
retrieving revision 1.46
retrieving revision 1.46.2.1
diff -u -w -d -r1.46 -r1.46.2.1
--- sqlradius.pm	21 Oct 2010 19:29:22 -0000	1.46
+++ sqlradius.pm	11 May 2011 15:23:56 -0000	1.46.2.1
@@ -610,6 +610,7 @@
 
   my $opt = {};
   my($start, $end, $svc_acct, $ip, $prefix) = ( '', '', '', '', '');
+  my $summarize = 0;
   if ( ref($_[0]) ) {
     $opt = shift;
     $start    = $opt->{stoptime_start};
@@ -617,6 +618,7 @@
     $svc_acct = $opt->{svc_acct};
     $ip       = $opt->{ip};
     $prefix   = $opt->{prefix};
+    $summarize   = $opt->{summarize};
   } else {
     ( $start, $end ) = splice(@_, 0, 2);
     $svc_acct = @_ ? shift : '';
@@ -644,6 +646,10 @@
                  "$str2time acctstoptime ) as acctstoptime",
                );
 
+  @fields = ( 'username', 'sum(acctsessiontime) as acctsessiontime', 'sum(acctinputoctets) as acctinputoctets',
+              'sum(acctoutputoctets) as acctoutputoctets',
+            ) if $summarize;
+
   my @param = ();
   my @where = ();
 
@@ -696,10 +702,14 @@
   my $where = join(' AND ', @where);
   $where = "WHERE $where" if $where;
 
+  my $groupby = '';
+  $groupby = 'GROUP BY username' if $summarize;
+
+  my $orderby = 'ORDER BY AcctStartTime DESC';
+  $orderby = '' if $summarize;
+
   my $sth = $dbh->prepare('SELECT '. join(', ', @fields).
-                          "  FROM radacct
-                             $where
-                             ORDER BY AcctStartTime DESC
+                          "  FROM radacct $where $groupby $orderby
   ") or die $dbh->errstr;                                 
   $sth->execute(@param) or die $sth->errstr;
 



More information about the freeside-commits mailing list