2006-04-14_snapshot
git-svn-id: svn://192.168.202.10@3 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# AST_VDhopper.pl version 0.4
|
||||
# AST_VDhopper.pl version 0.5
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# uses Net::MySQL to update the VICIDIAL leads hopper for the new streamlined
|
||||
@@ -29,6 +29,8 @@
|
||||
# 60215-1106 - Added Scheduled Callback release functionality
|
||||
# 60228-1623 - Change Callback activation to set the called_since_last_reset=N
|
||||
# 60228-1735 - Added hopper gmt validation to remove gmt outside of time range
|
||||
# 60320-0932 - Added inactive lead list hopper deletion (Thanks Vic Jolin)
|
||||
# 60322-1030 - Added super debug output
|
||||
#
|
||||
|
||||
# constants
|
||||
@@ -60,7 +62,7 @@ if (length($ARGV[0])>1)
|
||||
|
||||
if ($args =~ /--help/i)
|
||||
{
|
||||
print "allowed run time options(must stay in this order):\n [--debug] = debug\n [--dbgmt] = show GMT offset of records as they are inserted into hopper\n [-t] = test\n [--level=XXX] = force a hopper_level of XXX\n [--campaign=XXX] = run for campaign XXX only\n\n";
|
||||
print "allowed run time options(must stay in this order):\n [--debug] = debug\n [--debugX] = super debug\n [--dbgmt] = show GMT offset of records as they are inserted into hopper\n [-t] = test\n [--level=XXX] = force a hopper_level of XXX\n [--campaign=XXX] = run for campaign XXX only\n\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -85,7 +87,12 @@ if (length($ARGV[0])>1)
|
||||
if ($args =~ /--debug/i)
|
||||
{
|
||||
$DB=1;
|
||||
print "\n-----DEBUG -----\n\n";
|
||||
print "\n----- DEBUG -----\n\n";
|
||||
}
|
||||
if ($args =~ /--debugX/i)
|
||||
{
|
||||
$DBX=1;
|
||||
print "\n----- SUPER DEBUG -----\n\n";
|
||||
}
|
||||
if ($args =~ /--dbgmt/i)
|
||||
{
|
||||
@@ -131,7 +138,7 @@ if ($dbhA->has_selected_record)
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
$DBSERVER_GMT = "$record->[0]";
|
||||
if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;}
|
||||
if (length($DBSERVER_GMT)>0) {$SERVER_GMT = $DBSERVER_GMT;}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,6 +175,34 @@ if ($wipe_hopper_clean)
|
||||
exit;
|
||||
}
|
||||
|
||||
### Delete leads from inactive lists if there are any
|
||||
$stmtA = "SELECT * FROM vicidial_lists where active='N';";
|
||||
if ($DB) {print $stmtA;}
|
||||
$inactive_lists='';
|
||||
$inactive_lists_count=0;
|
||||
$dbhA->query("$stmtA");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
$inactive_list = $record->[0];
|
||||
$inactive_lists .= "'$inactive_list',";
|
||||
$inactive_lists_count++;
|
||||
}
|
||||
}
|
||||
if ($DB) {print "Inactive Lists: $inactive_lists_count\n";}
|
||||
|
||||
if ($inactive_lists_count > 0)
|
||||
{
|
||||
chop($inactive_lists);
|
||||
$stmtA = "DELETE from vicidial_hopper where list_id IN($inactive_lists);";
|
||||
$dbhA->query("$stmtA");
|
||||
my $affected_rows = $dbhA->get_affected_rows_length;
|
||||
if ($DB) {print "Inactive List Leads Deleted: $affected_rows |$stmtA|\n";}
|
||||
$event_string = "|INACTIVE LIST DEL|$affected_rows|";
|
||||
&event_logger;
|
||||
}
|
||||
|
||||
|
||||
### BEGIN Change CBHOLD status leads to CALLBK if their vicidial_callbacks time has passed
|
||||
@@ -332,22 +367,26 @@ foreach(@campaign_id)
|
||||
$GMT_allowed .= "'99'";
|
||||
|
||||
|
||||
if ($DB) {print "Starting hopper run for $campaign_id[$i] campaign: GMT: $local_call_time[$1] $GMT_allowed HOPPER: $hopper_level[$i] \n";}
|
||||
if ($DB) {print "Starting hopper run for $campaign_id[$i] campaign- GMT: $local_call_time[$1] $GMT_allowed HOPPER: $hopper_level[$i] \n";}
|
||||
|
||||
### Delete the DONE leads if there are any
|
||||
$stmtA = "DELETE from vicidial_hopper where campaign_id='$campaign_id[$i]' and status IN('DONE');";
|
||||
$dbhA->query("$stmtA");
|
||||
my $affected_rows = $dbhA->get_affected_rows_length;
|
||||
if ($DB) {print " hopper DONE cleared: $affected_rows\n";}
|
||||
if ($DBX) {print " |$stmtA|\n";}
|
||||
|
||||
### Delete the leads that are out of GMT time range if there are any
|
||||
$stmtA = "DELETE from vicidial_hopper where campaign_id='$campaign_id[$i]' and gmt_offset_now NOT IN($GMT_allowed);";
|
||||
$dbhA->query("$stmtA");
|
||||
my $affected_rows = $dbhA->get_affected_rows_length;
|
||||
if ($DB) {print " hopper GMT BAD cleared: $affected_rows\n";}
|
||||
if ($DBX) {print " |$stmtA|\n";}
|
||||
|
||||
### Find out how many leads are in the hopper from a specific campaign
|
||||
$hopper_ready_count=0;
|
||||
$dbhA->query("SELECT count(*) from vicidial_hopper where campaign_id='$campaign_id[$i]' and status='READY';");
|
||||
$stmtA = "SELECT count(*) from vicidial_hopper where campaign_id='$campaign_id[$i]' and status='READY';";
|
||||
$dbhA->query("$stmtA");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
@@ -356,6 +395,7 @@ foreach(@campaign_id)
|
||||
{
|
||||
$hopper_ready_count = $record->[0];
|
||||
if ($DB) {print " hopper READY count: $hopper_ready_count\n";}
|
||||
if ($DBX) {print " |$stmtA|\n";}
|
||||
$rec_countA++;
|
||||
}
|
||||
}
|
||||
@@ -367,7 +407,8 @@ foreach(@campaign_id)
|
||||
{
|
||||
if ($DB) {print " hopper too low ($hopper_ready_count|$hopper_level[$i]) starting hopper dump\n";}
|
||||
|
||||
$dbhA->query("SELECT list_id FROM vicidial_lists where campaign_id='$campaign_id[$i]' and active='Y';");
|
||||
$stmtA = "SELECT list_id FROM vicidial_lists where campaign_id='$campaign_id[$i]' and active='Y';";
|
||||
$dbhA->query("$stmtA");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
@@ -381,8 +422,10 @@ foreach(@campaign_id)
|
||||
chop($camp_lists);
|
||||
}
|
||||
if ($DB) {print " campaign lists count: $rec_countLISTS | $camp_lists\n";}
|
||||
if ($DBX) {print " |$stmtA|\n";}
|
||||
|
||||
$dbhA->query("SELECT count(*) FROM vicidial_list where called_since_last_reset='N' and status IN('$dial_status_a[$i]','$dial_status_b[$i]','$dial_status_c[$i]','$dial_status_d[$i]','$dial_status_e[$i]') and list_id IN($camp_lists) and gmt_offset_now IN($GMT_allowed)");
|
||||
$stmtA = "SELECT count(*) FROM vicidial_list where called_since_last_reset='N' and status IN('$dial_status_a[$i]','$dial_status_b[$i]','$dial_status_c[$i]','$dial_status_d[$i]','$dial_status_e[$i]') and list_id IN($camp_lists) and gmt_offset_now IN($GMT_allowed);";
|
||||
$dbhA->query("$stmtA");
|
||||
$campaign_leads_to_call=0;
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
@@ -391,11 +434,13 @@ foreach(@campaign_id)
|
||||
{
|
||||
$campaign_leads_to_call = "$record->[0]";
|
||||
if ($DB) {print " leads to call count: $campaign_leads_to_call\n";}
|
||||
if ($DBX) {print " |$stmtA|\n";}
|
||||
}
|
||||
}
|
||||
if ( ($lead_order[$i] eq "DOWN COUNT 2nd NEW") or ($lead_order[$i] eq "DOWN COUNT 3rd NEW") or ($lead_order[$i] eq "DOWN COUNT 4th NEW") )
|
||||
{
|
||||
$dbhA->query("SELECT count(*) FROM vicidial_list where called_since_last_reset='N' and status IN('NEW') and list_id IN($camp_lists) and gmt_offset_now IN($GMT_allowed)");
|
||||
$stmtA = "SELECT count(*) FROM vicidial_list where called_since_last_reset='N' and status IN('NEW') and list_id IN($camp_lists) and gmt_offset_now IN($GMT_allowed);";
|
||||
$dbhA->query("$stmtA");
|
||||
$NEW_campaign_leads_to_call=0;
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
@@ -404,6 +449,7 @@ foreach(@campaign_id)
|
||||
{
|
||||
$NEW_campaign_leads_to_call = "$record->[0]";
|
||||
if ($DB) {print " NEW leads to call count: $NEW_campaign_leads_to_call\n";}
|
||||
if ($DBX) {print " |$stmtA|\n";}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -423,7 +469,10 @@ foreach(@campaign_id)
|
||||
else
|
||||
{
|
||||
if ($DB) {print " Getting Leads to add to hopper\n";}
|
||||
$dbhA->query("SELECT lead_id FROM vicidial_hopper where campaign_id='$campaign_id[$i]';");
|
||||
### grab leads already in hopper so we don't duplicate
|
||||
$stmtA = "SELECT lead_id FROM vicidial_hopper where campaign_id='$campaign_id[$i]';";
|
||||
if ($DBX) {print " |$stmtA|\n";}
|
||||
$dbhA->query("$stmtA");
|
||||
$rec_countLISTS=0;
|
||||
$lead_id_lists = '';
|
||||
if ($dbhA->has_selected_record)
|
||||
@@ -461,7 +510,7 @@ foreach(@campaign_id)
|
||||
if ($DB) {print " looking for $NEW_level NEW leads mixed in with $OTHER_level other leads\n";}
|
||||
|
||||
$stmtA = "SELECT lead_id,list_id,gmt_offset_now,phone_number,state FROM vicidial_list where called_since_last_reset='N' and status IN('NEW') and list_id IN($camp_lists) and lead_id NOT IN($lead_id_lists) and gmt_offset_now IN($GMT_allowed) $order_stmt limit $NEW_level;";
|
||||
# if ($DB) {print " STMT |$stmtA|\n";}
|
||||
if ($DBX) {print " |$stmtA|\n";}
|
||||
$dbhA->query("$stmtA");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
@@ -487,7 +536,7 @@ foreach(@campaign_id)
|
||||
|
||||
if ($DB) {print " lead call order: $order_stmt\n";}
|
||||
$stmtA = "SELECT lead_id,list_id,gmt_offset_now,phone_number,state FROM vicidial_list where called_since_last_reset='N' and status IN('$dial_status_a[$i]','$dial_status_b[$i]','$dial_status_c[$i]','$dial_status_d[$i]','$dial_status_e[$i]') and list_id IN($camp_lists) and lead_id NOT IN($lead_id_lists) and gmt_offset_now IN($GMT_allowed) $order_stmt limit $OTHER_level;";
|
||||
# if ($DB) {print " STMT |$stmtA|\n";}
|
||||
if ($DBX) {print " |$stmtA|\n";}
|
||||
$dbhA->query("$stmtA");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user