[freeside-commits] freeside/FS/FS/part_export sqlradius.pm, 1.42.4.1, 1.42.4.2
Jeff Finucane,420,,
jeff at wavetail.420.am
Wed Aug 4 21:17:35 PDT 2010
Update of /home/cvs/cvsroot/freeside/FS/FS/part_export
In directory wavetail.420.am:/tmp/cvs-serv26054/FS/FS/part_export
Modified Files:
Tag: FREESIDE_1_9_BRANCH
sqlradius.pm
Log Message:
add options to only process account records from a particular realm and to ignore sessions that span billing periods RT8082
Index: sqlradius.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_export/sqlradius.pm,v
retrieving revision 1.42.4.1
retrieving revision 1.42.4.2
diff -u -w -d -r1.42.4.1 -r1.42.4.2
--- sqlradius.pm 14 Dec 2009 07:10:55 -0000 1.42.4.1
+++ sqlradius.pm 5 Aug 2010 04:17:33 -0000 1.42.4.2
@@ -22,6 +22,15 @@
type => 'checkbox',
label => 'Ignore accounting records from this database'
},
+ 'process_single_realm' => {
+ type => 'checkbox',
+ label => 'Only process one realm of accounting records',
+ },
+ 'realm' => { label => 'The realm of of accounting records to be processed' },
+ 'ignore_long_sessions' => {
+ type => 'checkbox',
+ label => 'Ignore sessions which span billing periods',
+ },
'hide_ip' => {
type => 'checkbox',
label => 'Hide IP address information on session reports',
@@ -617,7 +626,7 @@
if ( $svc_acct ) {
my $username = $self->export_username($svc_acct);
- if ( $svc_acct =~ /^([^@]+)\@([^@]+)$/ ) {
+ if ( $username =~ /^([^@]+)\@([^@]+)$/ ) {
push @where, '( UserName = ? OR ( UserName = ? AND Realm = ? ) )';
push @param, $username, $1, $2;
} else {
@@ -626,6 +635,11 @@
}
}
+ if ($self->option('process_single_realm')) {
+ push @where, 'Realm = ?';
+ push @param, $self->option('realm');
+ }
+
if ( length($ip) ) {
push @where, ' FramedIPAddress = ?';
push @param, $ip;
@@ -719,6 +733,15 @@
my $oldAutoCommit = $FS::UID::AutoCommit; # can't undo side effects, but at
local $FS::UID::AutoCommit = 0; # least we can avoid over counting
+ my $status = 'skipped';
+ my $errinfo = "for RADIUS detail RadAcctID $RadAcctId ".
+ "(UserName $UserName, Realm $Realm)";
+
+ if ( $self->option('process_single_realm')
+ && $self->option('realm') ne $Realm )
+ {
+ warn "WARNING: wrong realm $errinfo - skipping\n" if $DEBUG;
+ } else {
my @svc_acct =
grep { qsearch( 'export_svc', { 'exportnum' => $self->exportnum,
'svcpart' => $_->cust_svc->svcpart, } )
@@ -729,9 +752,6 @@
$extra_sql
);
- my $errinfo = "for RADIUS detail RadAcctID $RadAcctId ".
- "(UserName $UserName, Realm $Realm)";
- my $status = 'skipped';
if ( !@svc_acct ) {
warn "WARNING: no svc_acct record found $errinfo - skipping\n";
} elsif ( scalar(@svc_acct) > 1 ) {
@@ -744,8 +764,11 @@
$svc_acct->last_login($AcctStartTime);
$svc_acct->last_logout($AcctStopTime);
+ my $session_time = $AcctStopTime;
+ $session_time = $AcctStartTime if $self->option('ignore_long_sessions');
+
my $cust_pkg = $svc_acct->cust_svc->cust_pkg;
- if ( $cust_pkg && $AcctStopTime < ( $cust_pkg->last_bill
+ if ( $cust_pkg && $session_time < ( $cust_pkg->last_bill
|| $cust_pkg->setup ) ) {
$status = 'skipped (too old)';
} else {
@@ -758,6 +781,7 @@
$status=join(' ', @st);
}
}
+ }
warn "setting FreesideStatus to $status $errinfo\n" if $DEBUG;
my $psth = $dbh->prepare("UPDATE radacct
More information about the freeside-commits
mailing list