From 0390a76f7a7622450a8ac0814d63e5ca9bc9ebdc Mon Sep 17 00:00:00 2001 From: mattf Date: Fri, 9 Apr 2010 15:55:39 +0000 Subject: [PATCH] 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 --- .../branches/agc_2.2.0/bin/AST_VDhopper.pl | 63 ++++++++++++++----- agc_2-X/trunk/bin/AST_VDhopper.pl | 63 ++++++++++++++----- .../trunk/bin/VICIDIAL_IN_new_leads_file.pl | 2 +- 3 files changed, 97 insertions(+), 31 deletions(-) diff --git a/agc_2-X/branches/agc_2.2.0/bin/AST_VDhopper.pl b/agc_2-X/branches/agc_2.2.0/bin/AST_VDhopper.pl index b133d82a..6d4adcc3 100644 --- a/agc_2-X/branches/agc_2.2.0/bin/AST_VDhopper.pl +++ b/agc_2-X/branches/agc_2.2.0/bin/AST_VDhopper.pl @@ -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 LICENSE: AGPLv2 +# Copyright (C) 2010 Matt Florell 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++; } diff --git a/agc_2-X/trunk/bin/AST_VDhopper.pl b/agc_2-X/trunk/bin/AST_VDhopper.pl index b133d82a..6d4adcc3 100644 --- a/agc_2-X/trunk/bin/AST_VDhopper.pl +++ b/agc_2-X/trunk/bin/AST_VDhopper.pl @@ -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 LICENSE: AGPLv2 +# Copyright (C) 2010 Matt Florell 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++; } diff --git a/agc_2-X/trunk/bin/VICIDIAL_IN_new_leads_file.pl b/agc_2-X/trunk/bin/VICIDIAL_IN_new_leads_file.pl index 5e10d559..a0ab615b 100644 --- a/agc_2-X/trunk/bin/VICIDIAL_IN_new_leads_file.pl +++ b/agc_2-X/trunk/bin/VICIDIAL_IN_new_leads_file.pl @@ -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