[freeside-commits] freeside/FS/FS cdr_termination.pm, 1.3, 1.3.6.1 cdr.pm, 1.74.2.1, 1.74.2.2 svc_phone.pm, 1.39, 1.39.2.1

Ivan,,, ivan at wavetail.420.am
Thu Nov 17 16:09:54 PST 2011


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

Modified Files:
      Tag: FREESIDE_2_3_BRANCH
	cdr_termination.pm cdr.pm svc_phone.pm 
Log Message:
reduce memory usage of voip_tiered, RT#14903

Index: svc_phone.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/svc_phone.pm,v
retrieving revision 1.39
retrieving revision 1.39.2.1
diff -u -w -d -r1.39 -r1.39.2.1
--- svc_phone.pm	22 Jun 2011 18:32:21 -0000	1.39
+++ svc_phone.pm	18 Nov 2011 00:09:52 -0000	1.39.2.1
@@ -650,7 +650,7 @@
 
 =item for_update => 1: SELECT the CDRs "FOR UPDATE".
 
-=item status => "" (or "done"): Return only CDRs with that processing status.
+=item status => "" (or "processing-tiered", "done"): Return only CDRs with that processing status.
 
 =item inbound => 1: Return CDRs for inbound calls.  With "status", will filter 
 on inbound processing status.
@@ -673,25 +673,24 @@
   my @where;
 
   if ( $options{'inbound'} ) {
+
     @fields = ( 'dst' );
     if ( exists($options{'status'}) ) {
-      # must be 'done' or ''
-      my $sq = 'EXISTS ( SELECT 1 FROM cdr_termination '.
+      my $status = $options{'status'};
+      if ( $status ) {
+        push @where, 'EXISTS ( SELECT 1 FROM cdr_termination '.
+          'WHERE cdr.acctid = cdr_termination.acctid '.
+          "AND cdr_termination.status = '$status' ". #quoting kludge
+          'AND cdr_termination.termpart = 1 )';
+      } else {
+        push @where, 'NOT EXISTS ( SELECT 1 FROM cdr_termination '.
         'WHERE cdr.acctid = cdr_termination.acctid '.
-        'AND cdr_termination.status = \'done\' '.
         'AND cdr_termination.termpart = 1 )';
-      if ( $options{'status'} eq 'done' ) {
-        push @where, $sq;
-      }
-      elsif ($options{'status'} eq '' ) {
-        push @where, "NOT $sq";
-      }
-      else {
-        warn "invalid status: $options{'status'} (ignored)\n";
-      }
     }
   }
-  else {
+
+  } else {
+
     @fields = ( 'charged_party' );
     push @fields, 'src' if !$options{'disable_src'};
     $hash{'freesidestatus'} = $options{'status'}

Index: cdr.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cdr.pm,v
retrieving revision 1.74.2.1
retrieving revision 1.74.2.2
diff -u -w -d -r1.74.2.1 -r1.74.2.2
--- cdr.pm	14 Nov 2011 04:28:49 -0000	1.74.2.1
+++ cdr.pm	18 Nov 2011 00:09:52 -0000	1.74.2.2
@@ -130,9 +130,9 @@
 
 =item svcnum - Link to customer service (see L<FS::cust_svc>)
 
-=item freesidestatus - NULL, done (or something)
+=item freesidestatus - NULL, processing-tiered, done
 
-=item freesiderewritestatus - NULL, done (or something)
+=item freesiderewritestatus - NULL, done, skipped
 
 =item cdrbatch
 
@@ -404,10 +404,7 @@
 
   if ($opt{'inbound'}) {
 
-    my $term = qsearchs('cdr_termination', {
-        acctid   => $self->acctid, 
-        termpart => 1 # inbound
-    });
+    my $term = $self->cdr_termination( 1 ); #1: inbound
     my $error;
     if ( $term ) {
       warn "replacing existing cdr status (".$self->acctid.")\n" if $term;
@@ -419,10 +416,10 @@
         termpart    => 1,
         rated_price => $rated_price,
         status      => $status,
-        svcnum      => $svcnum,
     });
     $term->rated_seconds($opt{rated_seconds}) if exists($opt{rated_seconds});
     $term->rated_minutes($opt{rated_minutes}) if exists($opt{rated_minutes});
+    $term->svcnum($svcnum) if $svcnum;
     return $term->insert;
 
   } else {
@@ -437,6 +434,29 @@
   }
 }
 
+=item cdr_termination [ TERMPART ]
+
+=cut
+
+sub cdr_termination {
+  my $self = shift;
+
+  if ( scalar(@_) && $_[0] ) {
+    my $termpart = shift;
+
+    qsearchs('cdr_termination', { acctid   => $self->acctid,
+                                  termpart => $termpart,
+                                }
+            );
+
+  } else {
+
+    qsearch('cdr_termination', { acctid => $self->acctid, } );
+
+  }
+
+}
+
 =item calldate_unix 
 
 Parses the calldate in SQL string format and returns a UNIX timestamp.
@@ -753,11 +773,10 @@
     return $error;
   } 
 
-  my @cdr_termination = qsearch('cdr_termination', 
-				{ 'acctid' => $self->acctid } );
-  foreach my $cdr_termination ( @cdr_termination ) {
-      $cdr_termination->status('');
-      $error = $cdr_termination->replace;
+  foreach my $cdr_termination ( $self->cdr_termination ) {
+      #$cdr_termination->status('');
+      #$error = $cdr_termination->replace;
+      $error = $cdr_termination->delete;
       if ( $error ) {
 	$dbh->rollback if $oldAutoCommit;
 	return $error;

Index: cdr_termination.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cdr_termination.pm,v
retrieving revision 1.3
retrieving revision 1.3.6.1
diff -u -w -d -r1.3 -r1.3.6.1
--- cdr_termination.pm	27 Apr 2010 05:38:27 -0000	1.3
+++ cdr_termination.pm	18 Nov 2011 00:09:52 -0000	1.3.6.1
@@ -119,8 +119,8 @@
     || $self->ut_foreign_key('acctid', 'cdr', 'acctid')
     #|| $self->ut_foreign_key('termpart', 'part_termination', 'termpart')
     || $self->ut_number('termpart')
-    || $self->ut_float('rated_price')
-    || $self->ut_enum('status', [ '', 'done' ] ) # , 'skipped' ] )
+    || $self->ut_floatn('rated_price')
+    || $self->ut_enum('status', [ '', 'processing-tiered', 'done' ] ) # , 'skipped' ] )
   ;
   return $error if $error;
 



More information about the freeside-commits mailing list