Added vicidial_inbound_caller_codes logging to inbound call routing script

git-svn-id: svn://192.168.202.10@3495 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2021-08-19 12:38:48 +00:00
parent 96a08fcbab
commit bfd1d6d40f
4 changed files with 140 additions and 1 deletions
+24
View File
@@ -245,6 +245,7 @@
# 210325-2200 - Added populate_lead_comments option
# 210609-0941 - Added drop_call_seconds_override option
# 210804-0711 - Fix for closing time action issue #1321
# 210819-0029 - Added vicidial_inbound_caller_codes logging
#
$script = 'agi-VDAD_ALL_inbound.agi';
@@ -492,6 +493,9 @@ if ($callerid !~ /^V\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d|^Y\d\d\d\d\d\d\d\d\d\
if ( (!$callerid) or ($callerid =~ /unknown/) )
{$callerid = $calleridname;}
}
$prev_callerid = $callerid;
if ($calleridname =~ /^J\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d/)
{$prev_callerid = $calleridname;}
##### find out if this call is already in the vicidial_log_extended table
#$VLEcount=0;
@@ -1772,6 +1776,11 @@ if ( ( ( ( ($hm < $ct_default_start) || ($hm > $ct_default_stop) ) && ($hm >= $c
$dbhP=$dbhA; $mysql_count='02145'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- AH VLE insert: |$affected_rows|\n|$stmtA|"; &agi_output;}
$VLEcount++;
$stmtA = "INSERT INTO vicidial_inbound_caller_codes set uniqueid='$uniqueid',server_ip='$VARserver_ip',call_date='$now_date',lead_id = '$insert_lead_id',caller_code='$NACqueryCID',prev_caller_code='$prev_callerid',group_id='$channel_group';";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02XXX'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- AH VICC insert: |$affected_rows|\n|$stmtA|"; &agi_output;}
}
if ($enable_drop_lists > 0)
@@ -2345,6 +2354,11 @@ if ($VLEcount < 1)
$dbhP=$dbhA; $mysql_count='02147'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- ENTER QUEUE VLE insert: |$affected_rows|\n|$stmtA|"; &agi_output;}
$VLEcount++;
$stmtA = "INSERT INTO vicidial_inbound_caller_codes set uniqueid='$uniqueid',server_ip='$VARserver_ip',call_date='$now_date',lead_id = '$insert_lead_id',caller_code='$callerid',prev_caller_code='$prev_callerid',group_id='$channel_group';";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02XXX'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- ENTER QUEUE VICC insert: |$affected_rows|\n|$stmtA|"; &agi_output;}
}
@@ -4730,6 +4744,11 @@ while ( ($drop_timer <= $DROP_TIME) && ($wait_in_queue > 0) && ($MCdrop_override
$dbhP=$dbhA; $mysql_count='02146'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- ACFLTR VLE insert: |$affected_rows|\n|$stmtA|"; &agi_output;}
$VLEcount++;
$stmtA = "INSERT INTO vicidial_inbound_caller_codes set uniqueid='$uniqueid',server_ip='$VARserver_ip',call_date='$now_date',lead_id = '$insert_lead_id',caller_code='$NACqueryCID',prev_caller_code='$prev_callerid',group_id='$channel_group';";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02XXX'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- ACFLTR VICC insert: |$affected_rows|\n|$stmtA|"; &agi_output;}
}
if ($enable_drop_lists > 0)
@@ -8581,6 +8600,11 @@ sub no_agent_no_queue_process
$dbhP=$dbhA; $mysql_count='02146'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- NANQUE VLE insert: |$affected_rows|\n|$stmtA|"; &agi_output;}
$VLEcount++;
$stmtA = "INSERT INTO vicidial_inbound_caller_codes set uniqueid='$uniqueid',server_ip='$VARserver_ip',call_date='$now_date',lead_id = '$insert_lead_id',caller_code='$NACqueryCID',prev_caller_code='$prev_callerid',group_id='$channel_group';";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02XXX'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- NANQUE VICC insert: |$affected_rows|\n|$stmtA|"; &agi_output;}
}
if ($enable_drop_lists > 0)
+83
View File
@@ -61,6 +61,7 @@
# 201107-2206 - Added optional park_log archiving
# 210317-2104 - Added vicidial_agent_visibility_log archiving
# 210407-2023 - Added vicidial_peer_event_log archiving
# 210819-0826 - Added vicidial_inbound_caller_codes archiving
#
$CALC_TEST=0;
@@ -856,6 +857,35 @@ if (!$T)
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
}
##### END vicidial_xfer_log_archive trim processing #####
##### BEGIN vicidial_inbound_caller_codes_archive trim processing #####
$stmtA = "SELECT count(*) from vicidial_inbound_caller_codes_archive;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$vicidial_inbound_caller_codes_archive_count = $aryA[0];
}
$sthA->finish();
if (!$Q) {print "Trimming vicidial_inbound_caller_codes_archive table... ($vicidial_inbound_caller_codes_archive_count)\n";}
$rv = $sthA->err();
if (!$rv)
{
$stmtA = "DELETE FROM vicidial_inbound_caller_codes_archive WHERE call_date < '$del_time';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
if (!$Q) {print "$sthArows rows deleted from vicidial_inbound_caller_codes_archive table \n";}
$stmtA = "optimize table vicidial_inbound_caller_codes_archive;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
}
##### END vicidial_inbound_caller_codes_archive trim processing #####
}
if (!$Q) {print "Trim process complete, exiting...\n";}
@@ -1675,6 +1705,59 @@ if (!$T)
}
##### vicidial_inbound_caller_codes
$stmtA = "SELECT count(*) from vicidial_inbound_caller_codes;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$vicidial_inbound_caller_codes_count = $aryA[0];
}
$sthA->finish();
$stmtA = "SELECT count(*) from vicidial_inbound_caller_codes_archive;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$vicidial_inbound_caller_codes_archive_count = $aryA[0];
}
$sthA->finish();
if (!$Q) {print "\nProcessing vicidial_inbound_caller_codes table... ($vicidial_inbound_caller_codes_count|$vicidial_inbound_caller_codes_archive_count)\n";}
$stmtA = "INSERT IGNORE INTO vicidial_inbound_caller_codes_archive SELECT * from vicidial_inbound_caller_codes;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
if (!$Q) {print "$sthArows rows inserted into vicidial_inbound_caller_codes_archive table \n";}
$rv = $sthA->err();
if (!$rv)
{
if ($wipe_all > 0)
{$stmtA = "DELETE FROM vicidial_inbound_caller_codes;";}
else
{$stmtA = "DELETE FROM vicidial_inbound_caller_codes WHERE call_date < '$del_time';";}
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
if (!$Q) {print "$sthArows rows deleted from vicidial_inbound_caller_codes table \n";}
$stmtA = "optimize table vicidial_inbound_caller_codes;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$stmtA = "optimize table vicidial_inbound_caller_codes_archive;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
}
##### vicidial_log_extended
$stmtA = "SELECT count(*) from vicidial_log_extended;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
+16 -1
View File
@@ -4665,6 +4665,19 @@ KEY `start_date` (`start_date`),
KEY `khomp_id` (`khomp_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE vicidial_inbound_caller_codes (
uniqueid VARCHAR(50) NOT NULL,
server_ip VARCHAR(15),
call_date DATETIME,
group_id VARCHAR(20) NOT NULL,
lead_id INT(9) UNSIGNED,
caller_code VARCHAR(30) NOT NULL,
prev_caller_code VARCHAR(40) NOT NULL,
index (uniqueid),
index (call_date),
unique index cicc_cd (caller_code, uniqueid)
) ENGINE=MyISAM;
ALTER TABLE vicidial_email_list MODIFY message text character set utf8;
@@ -4923,6 +4936,8 @@ CREATE TABLE vicidial_agent_visibility_log_archive LIKE vicidial_agent_visibilit
CREATE TABLE vicidial_peer_event_log_archive LIKE vicidial_peer_event_log;
ALTER TABLE vicidial_peer_event_log_archive MODIFY peer_event_id INT(9) UNSIGNED NOT NULL;
CREATE TABLE vicidial_inbound_caller_codes_archive LIKE vicidial_inbound_caller_codes;
GRANT RELOAD ON *.* TO cron@'%';
GRANT RELOAD ON *.* TO cron@localhost;
@@ -5006,4 +5021,4 @@ INSERT INTO vicidial_settings_containers(container_id,container_notes,container_
UPDATE system_settings set vdc_agent_api_active='1';
UPDATE system_settings SET db_schema_version='1640',db_schema_update_date=NOW(),reload_timestamp=NOW();
UPDATE system_settings SET db_schema_version='1641',db_schema_update_date=NOW(),reload_timestamp=NOW();
+17
View File
@@ -1782,3 +1782,20 @@ UPDATE system_settings SET db_schema_version='1639',db_schema_update_date=NOW()
ALTER TABLE vicidial_campaigns ADD cid_group_id_two VARCHAR(20) default '---DISABLED---';
UPDATE system_settings SET db_schema_version='1640',db_schema_update_date=NOW() where db_schema_version < 1640;
CREATE TABLE vicidial_inbound_caller_codes (
uniqueid VARCHAR(50) NOT NULL,
server_ip VARCHAR(15),
call_date DATETIME,
group_id VARCHAR(20) NOT NULL,
lead_id INT(9) UNSIGNED,
caller_code VARCHAR(30) NOT NULL,
prev_caller_code VARCHAR(40) NOT NULL,
index (uniqueid),
index (call_date),
unique index cicc_cd (caller_code, uniqueid)
) ENGINE=MyISAM;
CREATE TABLE vicidial_inbound_caller_codes_archive LIKE vicidial_inbound_caller_codes;
UPDATE system_settings SET db_schema_version='1641',db_schema_update_date=NOW() where db_schema_version < 1641;