fixed rare issue in AST_VDhopper.pl script, slightly changed csv43 format in lead loader

git-svn-id: svn://192.168.202.10@1403 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2010-04-09 15:55:39 +00:00
parent 73f1a8a025
commit 0390a76f7a
3 changed files with 97 additions and 31 deletions
+48 -15
View File
@@ -23,7 +23,7 @@
# a minute, you may want to play with the variables below to streamline for
# your usage
#
# Copyright (C) 2009 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2010 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGELOG
# 50810-1613 - Added database server variable definitions lookup
@@ -61,6 +61,7 @@
# 90907-2132 - Fixed order issues
# 91020-0054 - Fixed Auto-alt-dial DNC issues
# 91026-1207 - Added AREACODE DNC option
# 100409-1101 - Fix for rare dial-time duplicate hopper load issue
#
# constants
@@ -147,6 +148,7 @@ if (length($ARGV[0])>1)
print " [-t] = test\n";
print " [--level=XXX] = force a hopper_level of XXX\n";
print " [--campaign=XXX] = run for campaign XXX only\n";
print " [--wipe-hopper-clean] = deletes everything from the hopper USE WITH CAUTION!!!\n";
print "\n";
exit;
}
@@ -2064,40 +2066,71 @@ foreach(@campaign_id)
if ($DBX) {print "Flagging DNC lead: $affected_rows $phone_to_hopper[$h] $campaign_id[$i]\n";}
}
}
if ($DNClead == '0')
{
$stmtA = "INSERT INTO $vicidial_hopper (lead_id,campaign_id,status,user,list_id,gmt_offset_now,state,priority) values('$leads_to_hopper[$h]','$campaign_id[$i]','READY','','$lists_to_hopper[$h]','$gmt_to_hopper[$h]','$state_to_hopper[$h]','0');";
$affected_rows = $dbhA->do($stmtA);
if ($DBX) {print "LEAD INSERTED: $affected_rows|$leads_to_hopper[$h]|\n";}
if ($DB_detail)
$VAC_exist=0;
$stmtA="SELECT count(*) FROM vicidial_auto_calls where lead_id='$leads_to_hopper[$h]';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
$detail_string = "|$campaign_id[$i]|$leads_to_hopper[$h]|$phone_to_hopper[$h]|$state_to_hopper[$h]|$gmt_to_hopper[$h]|$status_to_hopper[$h]|$modify_to_hopper[$h]|$user_to_hopper[$h]|";
&detail_logger;
@aryA = $sthA->fetchrow_array;
$VAC_exist = $aryA[0];
}
$sthA->finish();
$VLA_exist=0;
$stmtA="SELECT count(*) FROM vicidial_live_agents where lead_id='$leads_to_hopper[$h]';";
$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;
$VLA_exist = $aryA[0];
}
$sthA->finish();
if ( ($VAC_exist > 0) || ($VLA_exist > 0) )
{
$detail_string = "LIVE CALL SKIPPING |$VAC_exist|$VLA_exist| |$campaign_id[$i]|$leads_to_hopper[$h]|$phone_to_hopper[$h]|$state_to_hopper[$h]|$gmt_to_hopper[$h]|$status_to_hopper[$h]|$modify_to_hopper[$h]|$user_to_hopper[$h]|";
&detail_logger;
}
else
{
##### Auto-Alt-Dial if DNCC or DNCL are set to campaign auto-alt-dial statuses, insert lead into hopper as DNC status
if ( ( ($auto_alt_dial_statuses[$i] =~ / DNCC /) && ($DNCC > 0) ) || ( ($auto_alt_dial_statuses[$i] =~ / DNCL /) && ($DNCL > 0) ) )
if ($DNClead == '0')
{
$stmtA = "INSERT INTO $vicidial_hopper (lead_id,campaign_id,status,user,list_id,gmt_offset_now,state,priority) values('$leads_to_hopper[$h]','$campaign_id[$i]','DNC','','$lists_to_hopper[$h]','$gmt_to_hopper[$h]','$state_to_hopper[$h]','0');";
$stmtA = "INSERT INTO $vicidial_hopper (lead_id,campaign_id,status,user,list_id,gmt_offset_now,state,priority) values('$leads_to_hopper[$h]','$campaign_id[$i]','READY','','$lists_to_hopper[$h]','$gmt_to_hopper[$h]','$state_to_hopper[$h]','0');";
$affected_rows = $dbhA->do($stmtA);
if ($DBX) {print "LEAD INSERTED AS DNC: $affected_rows|$leads_to_hopper[$h]|\n";}
if ($DBX) {print "LEAD INSERTED: $affected_rows|$leads_to_hopper[$h]|\n";}
if ($DB_detail)
{
$detail_string = "|$campaign_id[$i]|$leads_to_hopper[$h]|$phone_to_hopper[$h]|$state_to_hopper[$h]|$gmt_to_hopper[$h]|$status_to_hopper[$h]|$modify_to_hopper[$h]|$user_to_hopper[$h]|";
&detail_logger;
}
}
else
{
##### Auto-Alt-Dial if DNCC or DNCL are set to campaign auto-alt-dial statuses, insert lead into hopper as DNC status
if ( ( ($auto_alt_dial_statuses[$i] =~ / DNCC /) && ($DNCC > 0) ) || ( ($auto_alt_dial_statuses[$i] =~ / DNCL /) && ($DNCL > 0) ) )
{
$stmtA = "INSERT INTO $vicidial_hopper (lead_id,campaign_id,status,user,list_id,gmt_offset_now,state,priority) values('$leads_to_hopper[$h]','$campaign_id[$i]','DNC','','$lists_to_hopper[$h]','$gmt_to_hopper[$h]','$state_to_hopper[$h]','0');";
$affected_rows = $dbhA->do($stmtA);
if ($DBX) {print "LEAD INSERTED AS DNC: $affected_rows|$leads_to_hopper[$h]|\n";}
if ($DB_detail)
{
$detail_string = "|$campaign_id[$i]|$leads_to_hopper[$h]|$phone_to_hopper[$h]|$state_to_hopper[$h]|$gmt_to_hopper[$h]|$status_to_hopper[$h]|$modify_to_hopper[$h]|$user_to_hopper[$h]|";
&detail_logger;
}
}
}
}
}
$h++;
}
if ($DB) {print " DONE with this campaign\n";}
}
}
}
$i++;
}
+48 -15
View File
@@ -23,7 +23,7 @@
# a minute, you may want to play with the variables below to streamline for
# your usage
#
# Copyright (C) 2009 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2010 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGELOG
# 50810-1613 - Added database server variable definitions lookup
@@ -61,6 +61,7 @@
# 90907-2132 - Fixed order issues
# 91020-0054 - Fixed Auto-alt-dial DNC issues
# 91026-1207 - Added AREACODE DNC option
# 100409-1101 - Fix for rare dial-time duplicate hopper load issue
#
# constants
@@ -147,6 +148,7 @@ if (length($ARGV[0])>1)
print " [-t] = test\n";
print " [--level=XXX] = force a hopper_level of XXX\n";
print " [--campaign=XXX] = run for campaign XXX only\n";
print " [--wipe-hopper-clean] = deletes everything from the hopper USE WITH CAUTION!!!\n";
print "\n";
exit;
}
@@ -2064,40 +2066,71 @@ foreach(@campaign_id)
if ($DBX) {print "Flagging DNC lead: $affected_rows $phone_to_hopper[$h] $campaign_id[$i]\n";}
}
}
if ($DNClead == '0')
{
$stmtA = "INSERT INTO $vicidial_hopper (lead_id,campaign_id,status,user,list_id,gmt_offset_now,state,priority) values('$leads_to_hopper[$h]','$campaign_id[$i]','READY','','$lists_to_hopper[$h]','$gmt_to_hopper[$h]','$state_to_hopper[$h]','0');";
$affected_rows = $dbhA->do($stmtA);
if ($DBX) {print "LEAD INSERTED: $affected_rows|$leads_to_hopper[$h]|\n";}
if ($DB_detail)
$VAC_exist=0;
$stmtA="SELECT count(*) FROM vicidial_auto_calls where lead_id='$leads_to_hopper[$h]';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
$detail_string = "|$campaign_id[$i]|$leads_to_hopper[$h]|$phone_to_hopper[$h]|$state_to_hopper[$h]|$gmt_to_hopper[$h]|$status_to_hopper[$h]|$modify_to_hopper[$h]|$user_to_hopper[$h]|";
&detail_logger;
@aryA = $sthA->fetchrow_array;
$VAC_exist = $aryA[0];
}
$sthA->finish();
$VLA_exist=0;
$stmtA="SELECT count(*) FROM vicidial_live_agents where lead_id='$leads_to_hopper[$h]';";
$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;
$VLA_exist = $aryA[0];
}
$sthA->finish();
if ( ($VAC_exist > 0) || ($VLA_exist > 0) )
{
$detail_string = "LIVE CALL SKIPPING |$VAC_exist|$VLA_exist| |$campaign_id[$i]|$leads_to_hopper[$h]|$phone_to_hopper[$h]|$state_to_hopper[$h]|$gmt_to_hopper[$h]|$status_to_hopper[$h]|$modify_to_hopper[$h]|$user_to_hopper[$h]|";
&detail_logger;
}
else
{
##### Auto-Alt-Dial if DNCC or DNCL are set to campaign auto-alt-dial statuses, insert lead into hopper as DNC status
if ( ( ($auto_alt_dial_statuses[$i] =~ / DNCC /) && ($DNCC > 0) ) || ( ($auto_alt_dial_statuses[$i] =~ / DNCL /) && ($DNCL > 0) ) )
if ($DNClead == '0')
{
$stmtA = "INSERT INTO $vicidial_hopper (lead_id,campaign_id,status,user,list_id,gmt_offset_now,state,priority) values('$leads_to_hopper[$h]','$campaign_id[$i]','DNC','','$lists_to_hopper[$h]','$gmt_to_hopper[$h]','$state_to_hopper[$h]','0');";
$stmtA = "INSERT INTO $vicidial_hopper (lead_id,campaign_id,status,user,list_id,gmt_offset_now,state,priority) values('$leads_to_hopper[$h]','$campaign_id[$i]','READY','','$lists_to_hopper[$h]','$gmt_to_hopper[$h]','$state_to_hopper[$h]','0');";
$affected_rows = $dbhA->do($stmtA);
if ($DBX) {print "LEAD INSERTED AS DNC: $affected_rows|$leads_to_hopper[$h]|\n";}
if ($DBX) {print "LEAD INSERTED: $affected_rows|$leads_to_hopper[$h]|\n";}
if ($DB_detail)
{
$detail_string = "|$campaign_id[$i]|$leads_to_hopper[$h]|$phone_to_hopper[$h]|$state_to_hopper[$h]|$gmt_to_hopper[$h]|$status_to_hopper[$h]|$modify_to_hopper[$h]|$user_to_hopper[$h]|";
&detail_logger;
}
}
else
{
##### Auto-Alt-Dial if DNCC or DNCL are set to campaign auto-alt-dial statuses, insert lead into hopper as DNC status
if ( ( ($auto_alt_dial_statuses[$i] =~ / DNCC /) && ($DNCC > 0) ) || ( ($auto_alt_dial_statuses[$i] =~ / DNCL /) && ($DNCL > 0) ) )
{
$stmtA = "INSERT INTO $vicidial_hopper (lead_id,campaign_id,status,user,list_id,gmt_offset_now,state,priority) values('$leads_to_hopper[$h]','$campaign_id[$i]','DNC','','$lists_to_hopper[$h]','$gmt_to_hopper[$h]','$state_to_hopper[$h]','0');";
$affected_rows = $dbhA->do($stmtA);
if ($DBX) {print "LEAD INSERTED AS DNC: $affected_rows|$leads_to_hopper[$h]|\n";}
if ($DB_detail)
{
$detail_string = "|$campaign_id[$i]|$leads_to_hopper[$h]|$phone_to_hopper[$h]|$state_to_hopper[$h]|$gmt_to_hopper[$h]|$status_to_hopper[$h]|$modify_to_hopper[$h]|$user_to_hopper[$h]|";
&detail_logger;
}
}
}
}
}
$h++;
}
if ($DB) {print " DONE with this campaign\n";}
}
}
}
$i++;
}
@@ -962,7 +962,7 @@ foreach(@FILES)
$title = $m[25]; # number of contacts
$address1 = $m[4]; $address1 =~ s/\s+$//gi;
$address2 = $m[5]; $address2 =~ s/\s+$//gi;
$address3 = $m[18]; # capture code
$address3 = $m[34]; # orig creditor
$city = $m[6]; $city =~ s/\s+$//gi;
$state = $m[7];
$province = $m[35]; $province =~ s/\s+$//gi; # balance