Fix for rare non-NA-set-as-NA call logging issue

git-svn-id: svn://192.168.202.10@3034 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2018-09-20 04:27:00 +00:00
parent 5d80ff5b7a
commit 8d57641dde
2 changed files with 82 additions and 72 deletions
+11 -9
View File
@@ -51,6 +51,7 @@
# 151109-1708 - Added new campaign feature allowing for different messages based on answering machine message wildcards # 151109-1708 - Added new campaign feature allowing for different messages based on answering machine message wildcards
# 170426-1711 - Fixed double-logging issue # 170426-1711 - Fixed double-logging issue
# 180529-1707 - Fix for missing called_count value in vicidial_log insertions # 180529-1707 - Fix for missing called_count value in vicidial_log insertions
# 180919-1831 - Fix for logging issue
# #
$script = 'VD_amd.agi'; $script = 'VD_amd.agi';
@@ -177,7 +178,7 @@ while(<STDIN>)
if (/^agi_priority\:\s+(.*)$/) {$priority = $1;} if (/^agi_priority\:\s+(.*)$/) {$priority = $1;}
if (/^agi_channel\:\s+(.*)$/) {$channel = $1;} if (/^agi_channel\:\s+(.*)$/) {$channel = $1;}
if (/^agi_extension\:\s+(.*)$/) {$extension = $1;} if (/^agi_extension\:\s+(.*)$/) {$extension = $1;}
if (/^agi_type\:\s+(.*)$/) {$type = $1;} if (/^agi_type\:\s+(.*)$/) {$type = $1;}
if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1; $calleridnum = $callerid;} if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1; $calleridnum = $callerid;}
if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;} if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;}
} }
@@ -293,7 +294,7 @@ else
########## FIND vicidial_auto_calls record ########## ########## FIND vicidial_auto_calls record ##########
$stmtA = "SELECT campaign_id,phone_code,phone_number,uniqueid,server_ip FROM vicidial_auto_calls where callerid='$callerid' order by auto_call_id desc limit 1;"; $stmtA = "SELECT campaign_id,phone_code,phone_number,uniqueid,server_ip,status FROM vicidial_auto_calls where callerid='$callerid' order by auto_call_id desc limit 1;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows; $sthArows=$sthA->rows;
@@ -301,11 +302,12 @@ else
if ($sthArows > 0) if ($sthArows > 0)
{ {
@aryA = $sthA->fetchrow_array; @aryA = $sthA->fetchrow_array;
$VD_campaign_id = $aryA[0]; $VD_campaign_id = $aryA[0];
$VD_phone_code = $aryA[1]; $VD_phone_code = $aryA[1];
$VD_phone_number = $aryA[2]; $VD_phone_number = $aryA[2];
$VD_uniqueid = $aryA[3]; $VD_uniqueid = $aryA[3];
$VD_server_ip = $aryA[4]; $VD_server_ip = $aryA[4];
$VD_status = $aryA[5];
$sthA->finish(); $sthA->finish();
} }
else else
@@ -361,9 +363,9 @@ else
$sthA->finish(); $sthA->finish();
########## UPDATE vicidial_auto_calls entry ########## ########## UPDATE vicidial_auto_calls entry ##########
$stmtA = "UPDATE vicidial_auto_calls set status='AA' where callerid='$callerid' order by auto_call_id desc limit 1;"; $stmtA = "UPDATE vicidial_auto_calls set status='XFER' where callerid='$callerid' order by auto_call_id desc limit 1;";
$affected_rows = $dbhA->do($stmtA); $affected_rows = $dbhA->do($stmtA);
if ($AGILOG) {$agi_string = "-- VDAC record updated: |$affected_rows| |$VD_lead_id|$uniqueid|$VD_callerid|$VD_server_ip"; &agi_output;} if ($AGILOG) {$agi_string = "-- VDAC record updated: |$affected_rows| |$VD_lead_id|$uniqueid|$callerid|$VD_status|$VD_server_ip"; &agi_output;}
########## FIND AND UPDATE vicidial_log ########## ########## FIND AND UPDATE vicidial_log ##########
$Euniqueid=$uniqueid; $Euniqueid=$uniqueid;
+71 -63
View File
@@ -81,6 +81,7 @@
# 170527-2340 - Fix for rare inbound logging issue #1017 # 170527-2340 - Fix for rare inbound logging issue #1017
# 170915-1753 - Asterisk 13 compatibility # 170915-1753 - Asterisk 13 compatibility
# 180521-1153 - Changed closer log logging to use agent if call was AGENTDIRECT # 180521-1153 - Changed closer log logging to use agent if call was AGENTDIRECT
# 180919-1729 - Fix for rare non-NA-set-as-NA call logging issue
# #
# defaults for PreFork # defaults for PreFork
@@ -995,86 +996,93 @@ sub process_request
} }
} }
$stmtA = "UPDATE vicidial_list set status='$VDL_status' where lead_id = '$CIDlead_id';"; if (length($VDL_status) > 0)
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$VDADaffected_rows = $dbhA->do($stmtA);
if ($AGILOG) {$agi_string = "-- VDAD vicidial_list update: |$VDADaffected_rows|$CIDlead_id"; &agi_output;}
$stmtA = "UPDATE vicidial_auto_calls set status='$VDAC_status' where callerid = '$callerid';";
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$VDACaffected_rows = $dbhA->do($stmtA);
if ($AGILOG) {$agi_string = "-- VDAC update: |$VDACaffected_rows|$CIDlead_id"; &agi_output;}
$Euniqueid=$uniqueid;
$Euniqueid =~ s/\.\d+$//gi;
$stmtA = "UPDATE vicidial_log FORCE INDEX(lead_id) set status='$VDL_status' where lead_id = '$CIDlead_id' and uniqueid LIKE \"$Euniqueid%\";";
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$VDLaffected_rows = $dbhA->do($stmtA);
if ($AGILOG) {$agi_string = "-- VDAD vicidial_log update: |$VDLaffected_rows|$uniqueid|$VDACuniqueid|"; &agi_output;}
if ($VDLaffected_rows < 1)
{ {
$VD_alt_dial = 'NONE'; $stmtA = "UPDATE vicidial_list set status='$VDL_status' where lead_id = '$CIDlead_id';";
$stmtA = "SELECT lead_id,callerid,campaign_id,alt_dial,stage,UNIX_TIMESTAMP(call_time),uniqueid,status,call_time,phone_code,phone_number,queue_position FROM vicidial_auto_calls where uniqueid = '$uniqueid' or callerid = '$callerid' limit 1;";
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $VDADaffected_rows = $dbhA->do($stmtA);
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; if ($AGILOG) {$agi_string = "-- VDAD vicidial_list update: |$VDADaffected_rows|$CIDlead_id"; &agi_output;}
$sthArows=$sthA->rows;
$rec_countCUSTDATA=0;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$VD_lead_id = $aryA[0];
$VD_callerid = $aryA[1];
$VD_campaign_id = $aryA[2];
$VD_alt_dial = $aryA[3];
$VD_stage = $aryA[4];
$VD_start_epoch = $aryA[5];
$VD_uniqueid = $aryA[6];
$VD_status = $aryA[7];
$VD_call_time = $aryA[8];
$VD_phone_code = $aryA[9];
$VD_phone_number = $aryA[10];
$VD_queue_position = $aryA[11];
$rec_countCUSTDATA++;
}
$sthA->finish();
if ($sthArows > 0) $stmtA = "UPDATE vicidial_auto_calls set status='$VDAC_status' where callerid = '$callerid';";
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$VDACaffected_rows = $dbhA->do($stmtA);
if ($AGILOG) {$agi_string = "-- VDAC update: |$VDACaffected_rows|$CIDlead_id"; &agi_output;}
$Euniqueid=$uniqueid;
$Euniqueid =~ s/\.\d+$//gi;
$stmtA = "UPDATE vicidial_log FORCE INDEX(lead_id) set status='$VDL_status' where lead_id = '$CIDlead_id' and uniqueid LIKE \"$Euniqueid%\";";
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$VDLaffected_rows = $dbhA->do($stmtA);
if ($AGILOG) {$agi_string = "-- VDAD vicidial_log update: |$VDLaffected_rows|$uniqueid|$VDACuniqueid|"; &agi_output;}
if ($VDLaffected_rows < 1)
{ {
$called_count=0; $VD_alt_dial = 'NONE';
$stmtA = "SELECT list_id,called_count FROM vicidial_list where lead_id='$VD_lead_id' limit 1;"; $stmtA = "SELECT lead_id,callerid,campaign_id,alt_dial,stage,UNIX_TIMESTAMP(call_time),uniqueid,status,call_time,phone_code,phone_number,queue_position FROM vicidial_auto_calls where uniqueid = '$uniqueid' or callerid = '$callerid' limit 1;";
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArowsVLd=$sthA->rows; $sthArows=$sthA->rows;
if ($sthArowsVLd > 0) $rec_countCUSTDATA=0;
if ($sthArows > 0)
{ {
@aryA = $sthA->fetchrow_array; @aryA = $sthA->fetchrow_array;
$VD_list_id = $aryA[0]; $VD_lead_id = $aryA[0];
$called_count = $aryA[1]; $VD_callerid = $aryA[1];
$VD_campaign_id = $aryA[2];
$VD_alt_dial = $aryA[3];
$VD_stage = $aryA[4];
$VD_start_epoch = $aryA[5];
$VD_uniqueid = $aryA[6];
$VD_status = $aryA[7];
$VD_call_time = $aryA[8];
$VD_phone_code = $aryA[9];
$VD_phone_number = $aryA[10];
$VD_queue_position = $aryA[11];
$rec_countCUSTDATA++;
} }
$sthA->finish(); $sthA->finish();
$vl_commentsSQL = ''; if ($sthArows > 0)
if ($callerid =~ /^M\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d/) {
{$vl_commentsSQL=",comments='MANUAL'";} $called_count=0;
$stmtA = "INSERT INTO vicidial_log SET uniqueid='$uniqueid',lead_id='$VD_lead_id',list_id='$VD_list_id',status='$VDL_status',campaign_id='$VD_campaign_id',call_date='$VD_call_time',start_epoch='$VD_start_epoch',phone_code='$VD_phone_code',phone_number='$VD_phone_number',user='VDAD',processed='N',length_in_sec='0',end_epoch='$VD_start_epoch',alt_dial='$VD_alt_dial',called_count='$called_count' $vl_commentsSQL;"; $stmtA = "SELECT list_id,called_count FROM vicidial_list where lead_id='$VD_lead_id' limit 1;";
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$VDLIaffected_rows = $dbhA->do($stmtA); $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
if ($AGILOG) {$agi_string = "-- VDAD vicidial_log insert: |$VDLIaffected_rows|$uniqueid|$CIDlead_id|$VDL_status|"; &agi_output;} $sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArowsVLd=$sthA->rows;
if ($sthArowsVLd > 0)
{
@aryA = $sthA->fetchrow_array;
$VD_list_id = $aryA[0];
$called_count = $aryA[1];
}
$sthA->finish();
$stmtA="INSERT IGNORE INTO vicidial_log_extended SET uniqueid='$uniqueid',server_ip='$VARserver_ip',call_date='$VD_call_time',lead_id='$VD_lead_id',caller_code='$VD_callerid',custom_call_id='' ON DUPLICATE KEY UPDATE server_ip='$VARserver_ip',call_date='$VD_call_time',lead_id='$VD_lead_id',caller_code='$VD_callerid';"; $vl_commentsSQL = '';
if ($callerid =~ /^M\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d/)
{$vl_commentsSQL=",comments='MANUAL'";}
$stmtA = "INSERT INTO vicidial_log SET uniqueid='$uniqueid',lead_id='$VD_lead_id',list_id='$VD_list_id',status='$VDL_status',campaign_id='$VD_campaign_id',call_date='$VD_call_time',start_epoch='$VD_start_epoch',phone_code='$VD_phone_code',phone_number='$VD_phone_number',user='VDAD',processed='N',length_in_sec='0',end_epoch='$VD_start_epoch',alt_dial='$VD_alt_dial',called_count='$called_count' $vl_commentsSQL;";
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$VDLIaffected_rows = $dbhA->do($stmtA);
if ($AGILOG) {$agi_string = "-- VDAD vicidial_log insert: |$VDLIaffected_rows|$uniqueid|$CIDlead_id|$VDL_status|"; &agi_output;}
$stmtA="INSERT IGNORE INTO vicidial_log_extended SET uniqueid='$uniqueid',server_ip='$VARserver_ip',call_date='$VD_call_time',lead_id='$VD_lead_id',caller_code='$VD_callerid',custom_call_id='' ON DUPLICATE KEY UPDATE server_ip='$VARserver_ip',call_date='$VD_call_time',lead_id='$VD_lead_id',caller_code='$VD_callerid';";
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$VDLXaffected_rows = $dbhA->do($stmtA);
if ($AGILOG) {$agi_string = "-- VDAD vicidial_extended_log insert: |$VDLXaffected_rows|$uniqueid|$CIDlead_id|$VDL_status|"; &agi_output;}
}
}
if ( ($CPDfound > 0) && ($VDL_status !~ /AA/) )
{
$stmtA = "DELETE FROM vicidial_auto_calls where callerid = '$callerid';";
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$VDLXaffected_rows = $dbhA->do($stmtA); $VDACDELaffected_rows = $dbhA->do($stmtA);
if ($AGILOG) {$agi_string = "-- VDAD vicidial_extended_log insert: |$VDLXaffected_rows|$uniqueid|$CIDlead_id|$VDL_status|"; &agi_output;} if ($AGILOG) {$agi_string = "-- CPD VDAC deleted: |$VDACDELaffected_rows|$callerid"; &agi_output;}
} }
} }
if ( ($CPDfound > 0) && ($VDL_status !~ /AA/) ) else
{ {
$stmtA = "DELETE FROM vicidial_auto_calls where callerid = '$callerid';"; if ($AGILOG) {$agi_string = "-- VD_hangup Local STATUS EMPTY: |$PRI|$callerid|$dialstatus|$hangup_cause|$CPDfound|$VDL_status|"; &agi_output;}
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$VDACDELaffected_rows = $dbhA->do($stmtA);
if ($AGILOG) {$agi_string = "-- CPD VDAC deleted: |$VDACDELaffected_rows|$callerid"; &agi_output;}
} }
} }
else else