[freeside-commits] branch FREESIDE_3_BRANCH updated. a4ce3adf4f21c0e4678785fe6a1eea03e1bdcd1b

Ivan ivan at 420.am
Mon Mar 20 10:31:01 PDT 2017


The branch, FREESIDE_3_BRANCH has been updated
       via  a4ce3adf4f21c0e4678785fe6a1eea03e1bdcd1b (commit)
      from  3c0ff0c5eb04fefa05f2f2a01b1c59000f26117b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit a4ce3adf4f21c0e4678785fe6a1eea03e1bdcd1b
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Mon Mar 20 10:31:00 2017 -0700

    asterisk v12 CDRs, RT#71704

diff --git a/FS/bin/freeside-cdr-asterisk_sql b/FS/bin/freeside-cdr-asterisk_sql
index a266f14..78ef7a5 100755
--- a/FS/bin/freeside-cdr-asterisk_sql
+++ b/FS/bin/freeside-cdr-asterisk_sql
@@ -43,8 +43,8 @@ if ( $engine =~ /^mysql/ ) {
 }
 
 my @cols = ();
-if ( $opt{V} > 12 ) {
-  push @cols, qw( start answer end );
+if ( $opt{V} >= 12 ) {
+  push @cols, qw( id start answer end );
 } else {
   push @cols, qw( calldate );
 }
@@ -85,11 +85,12 @@ while ( my $row = $sth->fetchrow_hashref ) {
 
   my $cdr = FS::cdr->new($row);
 
-  if ( $opt{V} > 12 ) {
+  if ( $opt{V} >= 12 ) {
     $cdr->calldate($cdr->start);
     $cdr->startdate(str2time($cdr->start));
     $cdr->answerdate(str2time($cdr->answer));
     $cdr->enddate(str2time($cdr->end));
+    $cdr->cdrid($cdr->id);
   } else {
     $cdr->startdate(str2time($cdr->calldate));
   }
@@ -100,19 +101,25 @@ while ( my $row = $sth->fetchrow_hashref ) {
   if ($error) {
     warn "failed import: $error\n";
   } else {
+
     $imports++;
-    if( $dbi->do("UPDATE cdr SET freesidestatus = 'done' 
-        WHERE calldate = ? AND src = ? AND dst = ?",
-                undef,
-                $row->{'calldate'},
-                $row->{'src'},
-                $row->{'dst'},
-
-      ) ) {
-        $updates++;
+
+    my $where = '';
+    my @args = ();
+    if ( $opt{V} >= 12 ) {
+      $where = 'id = '. $row->{'id'};
+      @args = ( undef );
+    } else {
+      $where = 'calldate = ? AND src = ? AND dst = ?';
+      @args = ( undef, $row->{'calldate'}, $row->{'src'}, $row->{'dst'}, );
+    }
+
+    if ( $dbi->do("UPDATE $table SET freesidestatus = 'done' $where", @args) ) {
+      $updates++;
     } else {
       warn "failed to set status: ".$dbi->errstr."\n";
     }
+
   }
 
 }

-----------------------------------------------------------------------

Summary of changes:
 FS/bin/freeside-cdr-asterisk_sql |   31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)




More information about the freeside-commits mailing list