Adapt script change to run for campaigns with live agents but no hopper leads

formatting fixes

git-svn-id: svn://192.168.202.10@1764 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2011-12-23 16:23:37 +00:00
parent 646723e94e
commit 6b52a6dc69
+31 -10
View File
@@ -37,6 +37,7 @@
# 110513-0721 - Added debug DB table, dial level and available only tally threshold options
# 111103-0626 - Added MAXCAL as a drop status
# 111219-1420 - Added daily stats updates to new table for total, in-group and campaign
# 111223-0924 - Added check for logged-in agents
#
# constants
@@ -44,7 +45,7 @@ $DB=0; # Debug flag, set to 0 for no debug messages, On an active system this w
$US='__';
$MT[0]='';
##### table definitions:
##### table definitions(used to force index usage for better performance):
$vicidial_log = 'vicidial_log FORCE INDEX (call_date) ';
# $vicidial_log = 'vicidial_log';
$vicidial_closer_log = 'vicidial_closer_log FORCE INDEX (call_date) ';
@@ -111,11 +112,12 @@ if (length($ARGV[0])>1)
print " [--loops=XXX] = force a number of loops of XXX\n";
print " [--delay=XXX] = force a loop delay of XXX seconds\n";
print " [--campaign=XXX] = run for campaign XXX only\n";
print " [--no-daily-stats] = will not daily stats for total, ingroup, campaign\n";
print " [--no-daily-stats] = will not calculate daily stats for total, ingroup, campaign\n";
print " [--force] = force calculation of suggested predictive dial_level\n";
print " [--test] = test only, do not alter dial_level\n";
print " [--debug] = debug\n";
print " [--debugX] = super debug\n";
print " [--debugXXX] = extra super debug\n";
print "\n";
exit;
}
@@ -201,6 +203,11 @@ if (length($ARGV[0])>1)
print "CLIdelay- $CLIdelay\n";
print "\n";
}
if ($args =~ /--debugXXX/i)
{
$DBXXX=1;
print "\n----- EXTRA SUPER DEBUG -----\n\n";
}
if ($args =~ /--force/i)
{
$force_test=1;
@@ -338,8 +345,8 @@ while ($master_loop<$CLIloops)
while ($sthArows > $rec_count)
{
@aryA = $sthA->fetchrow_array;
$DBvd_server_logs = "$aryA[0]";
$DBSERVER_GMT = "$aryA[1]";
$DBvd_server_logs = $aryA[0];
$DBSERVER_GMT = $aryA[1];
if ($DBvd_server_logs =~ /Y/) {$SYSLOG = '1';}
else {$SYSLOG = '0';}
if (length($DBSERVER_GMT)>0) {$SERVER_GMT = $DBSERVER_GMT;}
@@ -347,7 +354,6 @@ while ($master_loop<$CLIloops)
}
$sthA->finish();
$secX = time();
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($secX);
$LOCAL_GMT_OFF = $SERVER_GMT;
@@ -364,7 +370,7 @@ while ($master_loop<$CLIloops)
if ($min < 10) {$min = "0$min";}
if ($sec < 10) {$sec = "0$sec";}
# if ($DB) {print "TIME DEBUG: $master_loop $LOCAL_GMT_OFF_STD|$LOCAL_GMT_OFF|$isdst| GMT: $hour:$min\n";}
if ($DBXXX) {print "TIME DEBUG: $master_loop $LOCAL_GMT_OFF_STD|$LOCAL_GMT_OFF|$isdst| GMT: $hour:$min\n";}
@campaign_id=@MT;
@lead_order=@MT;
@@ -445,8 +451,9 @@ while ($master_loop<$CLIloops)
foreach(@campaign_id)
{
$debug_camp_output='';
### Find out how many leads are in the hopper from a specific campaign
$hopper_ready_count=0;
$agents_loggedin_count=0;
### Find out how many leads are in the hopper from a specific campaign
$stmtA = "SELECT count(*) from vicidial_hopper where campaign_id='$campaign_id[$i]' and status='READY';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
@@ -457,7 +464,21 @@ while ($master_loop<$CLIloops)
$hopper_ready_count = $aryA[0];
if ($DB) {print " $campaign_id[$i] hopper READY count: $hopper_ready_count";}
$debug_camp_output .= " $campaign_id[$i] hopper READY count: $hopper_ready_count\n";
# if ($DBX) {print " |$stmtA|\n";}
if ($DBXXX) {print " |$stmtA|\n";}
}
$sthA->finish();
### Find out how many agents are logged in to a specific campaign
$stmtA = "SELECT count(*) from vicidial_live_agents where campaign_id='$campaign_id[$i]' and last_update_time > '$VDL_one';";
$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;
$agents_loggedin_count = $aryA[0];
if ($DB) {print " $campaign_id[$i] agents LOGGED-IN count: $agents_loggedin_count";}
$debug_camp_output .= " $campaign_id[$i] agents LOGGED-IN count: $agents_loggedin_count\n";
if ($DBXXX) {print " |$stmtA|\n";}
}
$sthA->finish();
$event_string = "|$campaign_id[$i]|$hopper_level[$i]|$hopper_ready_count|$local_call_time[$i]|$diff_ratio_updater|$drop_count_updater|";
@@ -468,8 +489,8 @@ while ($master_loop<$CLIloops)
if ($DBX) {print " TIME CALL CHECK: $five_min_ago/$campaign_calldate_epoch[$i]\n";}
$debug_camp_output .= " TIME CALL CHECK: $five_min_ago/$campaign_calldate_epoch[$i]\n";
##### IF THERE ARE NO LEADS IN THE HOPPER FOR THE CAMPAIGN WE DO NOT WANT TO ADJUST THE DIAL_LEVEL
if ($hopper_ready_count>0)
##### IF THERE ARE NO LEADS IN THE HOPPER OR AGENTS LOGGED-IN FOR THE CAMPAIGN WE DO NOT WANT TO ADJUST THE DIAL_LEVEL
if ( ($hopper_ready_count > 0) || ($agents_loggedin_count > 0) )
{
### BEGIN - GATHER STATS FOR THE vicidial_campaign_stats TABLE ###
$differential_onemin[$i]=0;