[freeside-commits] branch FREESIDE_4_BRANCH updated. 32cfce396c2588bec65ef71785f9f059fd51426c

Ivan Kohler ivan at freeside.biz
Thu Aug 29 14:54:37 PDT 2019


The branch, FREESIDE_4_BRANCH has been updated
       via  32cfce396c2588bec65ef71785f9f059fd51426c (commit)
      from  19e6dd49237e59355b6cf193b9f6b49bf361b9d0 (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 32cfce396c2588bec65ef71785f9f059fd51426c
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Thu Aug 29 14:54:03 2019 -0700

    work around missing id, RT#83146

diff --git a/FS/bin/freeside-cdr-asterisk_sql b/FS/bin/freeside-cdr-asterisk_sql
index 2c4204548..a5a570d60 100755
--- a/FS/bin/freeside-cdr-asterisk_sql
+++ b/FS/bin/freeside-cdr-asterisk_sql
@@ -13,7 +13,7 @@ use Getopt::Std;
 $DEBUG = 0;
 
 my %opt;
-getopts('e:H:U:P:D:T:V:', \%opt);
+getopts('e:H:U:P:D:T:V:Q', \%opt);
 my $user = shift or die &usage;
 
 my $engine = $opt{e} || 'mysql';
@@ -56,12 +56,18 @@ if ( $engine =~ /^mysql/ ) {
 
 my @cols = ();
 if ( $opt{V} >= 12 ) {
-  push @cols, qw( id start answer );
+
+  push @cols, qw( id )
+    unless $opt{Q};
+
+  push @cols, qw( start answer );
+
   if ( $engine =~ /^Pg/ ) {
     push @cols, "'end'";
   } else {
     push @cols, "end";
   }
+
 } else {
   push @cols, qw( calldate );
 }
@@ -138,8 +144,13 @@ while ( my $row = $sth->fetchrow_hashref ) {
     my $usql = "UPDATE $table SET freesidestatus = 'done' WHERE ";
     my @args = ();
     if ( $opt{V} >= 12 ) {
-      $usql .= ' id = '. $row->{'id'};
-      @args = ( undef );
+      if ( $row->{'id'} ) {
+        $usql .= ' id = '. $row->{'id'};
+        @args = ( undef );
+      } else {
+        $usql .= ' uniqueid = ?';
+        @args = ( $row->{'uniqueid'} );
+      }
     } else {
       $usql .= ' calldate = ? AND src = ? AND dst = ?';
       @args = ( undef, $row->{'calldate'}, $row->{'src'}, $row->{'dst'}, );
@@ -216,6 +227,8 @@ Imports CDR records from an Asterisk SQL database.
 
 -V: Asterisk version.  Values of 12 or higher have a new database schema which no longer includes calldate.  Currently defaults to 11, but may default to 12+ or be required in a future, so best to always specify the version.
 
+-Q: Use uniqueid field instead of id (Asterisk v12 only).  Less efficient, but useful if the field is missing.
+
 =cut
 
 1;

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

Summary of changes:
 FS/bin/freeside-cdr-asterisk_sql | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)




More information about the freeside-commits mailing list