diff --git a/bin/AST_VDauto_dial.pl b/bin/AST_VDauto_dial.pl
index 5c9c8b86..98349788 100644
--- a/bin/AST_VDauto_dial.pl
+++ b/bin/AST_VDauto_dial.pl
@@ -207,6 +207,7 @@ while($one_day_interval > 0)
{
$endless_loop=5760000; # 30 days minutes at XXX seconds per loop
+ $stat_count=1;
while($endless_loop > 0)
{
@@ -237,6 +238,7 @@ while($one_day_interval > 0)
@DBIPexistcalls=@MT;
@DBIPgoalcalls=@MT;
@DBIPmakecalls=@MT;
+ @DBIPlivecalls=@MT;
@DBIPclosercamp=@MT;
@DBIPomitcode=@MT;
@@ -405,6 +407,93 @@ while($one_day_interval > 0)
$event_string="$DBIPcampaign[$user_CIPct] $DBIPaddress[$user_CIPct]: Calls to place: $DBIPmakecalls[$user_CIPct] ($DBIPgoalcalls[$user_CIPct] - $DBIPexistcalls[$user_CIPct]) $MVT_msg";
&event_logger;
+
+
+ ### Calculate campaign-wide agent waiting and calls waiting differential
+ ### This is used by the AST_VDadapt script to see if the current dial_level
+ ### should be changed at all
+ $total_agents=0;
+ $ready_agents=0;
+ $waiting_calls=0;
+
+ $stmtA = "SELECT count(*),status from vicidial_live_agents where campaign_id='$DBIPcampaign[$user_CIPct]' and last_update_time > '$halfminSQLdate' group by status;";
+ $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
+ $sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
+ $sthArows=$sthA->rows;
+ $rec_count=0;
+ while ($sthArows > $rec_count)
+ {
+ @aryA = $sthA->fetchrow_array;
+ $VCSagent_count = "$aryA[0]";
+ $VCSagent_status = "$aryA[1]";
+ $rec_count++;
+ if ($VCSagent_status =~ /READY|DONE/) {$ready_agents = ($ready_agents + $VCSagent_count);}
+ $total_agents = ($total_agents + $VCSagent_count);
+ }
+ $sthA->finish();
+
+ $stmtA = "SELECT count(*) FROM vicidial_auto_calls where $campaign_query and status IN('LIVE');";
+ $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
+ $sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
+ $sthArows=$sthA->rows;
+ $rec_count=0;
+ while ($sthArows > $rec_count)
+ {
+ @aryA = $sthA->fetchrow_array;
+ $waiting_calls = "$aryA[0]";
+ $rec_count++;
+ }
+ $sthA->finish();
+
+ $stat_ready_agents[$user_CIPct][$stat_count] = $ready_agents;
+ $stat_waiting_calls[$user_CIPct][$stat_count] = $waiting_calls;
+ $stat_total_agents[$user_CIPct][$stat_count] = $total_agents;
+
+ $stat_it=20;
+ $ready_diff_total=0;
+ $waiting_diff_total=0;
+ $total_agents_total=0;
+ $ready_diff_avg=0;
+ $waiting_diff_avg=0;
+ $total_agents_avg=0;
+ $stat_differential=0;
+ if ($stat_count < 20)
+ {
+ $stat_it = $stat_count;
+ $stat_B = 1;
+ }
+ else
+ {
+ $stat_B = ($stat_count - 19);
+ }
+
+ $it=0;
+ while($it < $stat_it)
+ {
+ $it_ary = ($it + $stat_B);
+ $ready_diff_total = ($ready_diff_total + $stat_ready_agents[$user_CIPct][$it_ary]);
+ $waiting_diff_total = ($waiting_diff_total + $stat_waiting_calls[$user_CIPct][$it_ary]);
+ $total_agents_total = ($total_agents_total + $stat_total_agents[$user_CIPct][$it_ary]);
+ # $event_string="$stat_count $it_ary $stat_total_agents[$user_CIPct][$it_ary]|$stat_ready_agents[$user_CIPct][$it_ary]|$stat_waiting_calls[$user_CIPct][$it_ary]";
+ # &event_logger;
+ $it++;
+ }
+
+ if ($ready_diff_total > 0)
+ {$ready_diff_avg = ($ready_diff_total / $stat_it);}
+ if ($waiting_diff_total > 0)
+ {$waiting_diff_avg = ($waiting_diff_total / $stat_it);}
+ if ($total_agents_total > 0)
+ {$total_agents_avg = ($total_agents_total / $stat_it);}
+ $stat_differential = ($ready_diff_avg - $waiting_diff_avg);
+
+ $event_string="CAMPAIGN DIFFERENTIAL: $total_agents_avg $stat_differential ($ready_diff_avg - $waiting_diff_avg)";
+ &event_logger;
+
+ $stmtA = "UPDATE vicidial_campaign_stats SET differential_onemin='$stat_differential', agents_average_onemin='$total_agents_avg' where campaign_id='$DBIPcampaign[$user_CIPct]';";
+ $affected_rows = $dbhA->do($stmtA);
+
+
$user_CIPct++;
}
@@ -849,15 +938,15 @@ while($one_day_interval > 0)
$i=0;
foreach (@psoutput)
- {
- chomp($psoutput[$i]);
+ {
+ chomp($psoutput[$i]);
- @psline = split(/\/usr\/bin\/perl /,$psoutput[$i]);
+ @psline = split(/\/usr\/bin\/perl /,$psoutput[$i]);
- if ($psline[1] =~ /AST_manager_li/) {$running_listen++;}
+ if ($psline[1] =~ /AST_manager_li/) {$running_listen++;}
- $i++;
- }
+ $i++;
+ }
if (!$running_listen)
{
@@ -871,7 +960,7 @@ while($one_day_interval > 0)
$bad_grabber_counter=0;
-
+ $stat_count++;
}
@@ -960,6 +1049,7 @@ if ($Phour < 10) {$Phour = "0$Phour";}
if ($Pmin < 10) {$Pmin = "0$Pmin";}
if ($Psec < 10) {$Psec = "0$Psec";}
$PDtsSQLdate = "$Pyear$Pmon$Pmday$Phour$Pmin$Psec";
+ $halfminSQLdate = "$Pyear-$Pmon-$Pmday $Phour:$Pmin:$Psec";
$XDtarget = ($secX - 120);
($Xsec,$Xmin,$Xhour,$Xmday,$Xmon,$Xyear,$Xwday,$Xyday,$Xisdst) = localtime($XDtarget);
diff --git a/extras/MySQL_AST_CREATE_tables.sql b/extras/MySQL_AST_CREATE_tables.sql
index c42b8269..e5706c3a 100644
--- a/extras/MySQL_AST_CREATE_tables.sql
+++ b/extras/MySQL_AST_CREATE_tables.sql
@@ -753,7 +753,9 @@ drops_fivemin INT(9) UNSIGNED default '0',
drops_fivemin_pct VARCHAR(6) default '0',
calls_onemin INT(9) UNSIGNED default '0',
drops_onemin INT(9) UNSIGNED default '0',
-drops_onemin_pct VARCHAR(6) default '0'
+drops_onemin_pct VARCHAR(6) default '0',
+differential_onemin VARCHAR(20) default '0',
+agents_average_onemin VARCHAR(20) default '0'
);
CREATE TABLE vicidial_dnc (
diff --git a/extras/upgrade_2.0.1.sql b/extras/upgrade_2.0.1.sql
index bfe45215..394f8282 100644
--- a/extras/upgrade_2.0.1.sql
+++ b/extras/upgrade_2.0.1.sql
@@ -23,3 +23,6 @@ ALTER TABLE vicidial_campaigns ADD available_only_ratio_tally ENUM('Y','N') defa
ALTER TABLE vicidial_campaigns ADD adaptive_dropped_percentage SMALLINT(3) default '3';
ALTER TABLE vicidial_campaigns ADD adaptive_maximum_level VARCHAR(6) default '3.0';
ALTER TABLE vicidial_campaigns ADD adaptive_latest_target_gmt VARCHAR(6) default '-7';
+
+ALTER TABLE vicidial_campaign_stats ADD differential_onemin VARCHAR(20) default '0';
+ALTER TABLE vicidial_campaign_stats ADD agents_average_onemin VARCHAR(20) default '0';
diff --git a/www/vicidial/AST_timeonVDADall.php b/www/vicidial/AST_timeonVDADall.php
index aacd518c..4cf25f00 100644
--- a/www/vicidial/AST_timeonVDADall.php
+++ b/www/vicidial/AST_timeonVDADall.php
@@ -180,10 +180,11 @@ echo "\n\n";
if (!$group) {echo "
please select a campaign from the pulldown above\n"; exit;}
else
{
-$stmt="select auto_dial_level,dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,lead_filter_id,hopper_level from vicidial_campaigns where campaign_id='" . mysql_real_escape_string($group) . "';";
+$stmt="select auto_dial_level,dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,lead_filter_id,hopper_level,dial_method from vicidial_campaigns where campaign_id='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$HOPlev = $row[8];
+$DIALmethod = $row[9];
echo "
| DIAL LEVEL: | $row[0] | "; @@ -197,13 +198,21 @@ $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $VDhop = $row[0]; -$stmt="select dialable_leads,calls_today,drops_today,drops_today_pct from vicidial_campaign_stats where campaign_id='" . mysql_real_escape_string($group) . "';"; +$stmt="select dialable_leads,calls_today,drops_today,drops_today_pct,differential_onemin,agents_average_onemin from vicidial_campaign_stats where campaign_id='" . mysql_real_escape_string($group) . "';"; $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $DAleads = $row[0]; $callsTODAY = $row[1]; $dropsTODAY = $row[2]; $drpctTODAY = $row[3]; +$diffONEMIN = $row[4]; +$agentsONEMIN = $row[5]; +if ( ($diffONEMIN != 0) and ($agentsONEMIN > 0) ) + { + $diffpctONEMIN = ( ($diffONEMIN / $agentsONEMIN) * 100); + $diffpctONEMIN = sprintf("%01.2f", $diffpctONEMIN); + } +else {$diffpctONEMIN = '0.00';} echo "|||||||
| HOPPER LEVEL: | $HOPlev | "; @@ -216,6 +225,13 @@ echo "CALLS TODAY: | CALLS DROPPED: | $dropsTODAY | "; echo "DROPPED PERCENT: | $drpctTODAY% | "; echo "$NOW_TIME | "; +echo "|
| DIAL METHOD: | $DIALmethod | "; +echo "DL DIFF: | $diffONEMIN | "; +echo "AVG AGENTS: | $agentsONEMIN | "; +echo "DIFF: | $diffpctONEMIN% | "; + echo "|