From 70c2e655671d920cf91aded5786ff7ee2f1c4a79 Mon Sep 17 00:00:00 2001 From: mattf Date: Fri, 26 Aug 2022 05:12:32 +0000 Subject: [PATCH] Added option to remove older leads in the DEDUPE perl script git-svn-id: svn://192.168.202.10@3621 3d104415-ff17-0410-8863-d5cf3c621b8a --- agc_2-X/trunk/bin/VICIDIAL_DEDUPE_leads.pl | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/agc_2-X/trunk/bin/VICIDIAL_DEDUPE_leads.pl b/agc_2-X/trunk/bin/VICIDIAL_DEDUPE_leads.pl index 2b0abe8e..87fd735b 100644 --- a/agc_2-X/trunk/bin/VICIDIAL_DEDUPE_leads.pl +++ b/agc_2-X/trunk/bin/VICIDIAL_DEDUPE_leads.pl @@ -10,7 +10,8 @@ # /usr/share/astguiclient/VICIDIAL_DEDUPE_leads.pl --debugX --campaign-duplicate=CTF --ignore-list=999 # # CHANGES -# 70521-1643 - first build +# 070521-1643 - first build +# 220825-0958 - Added option to remove older leads # $secX = time(); @@ -97,6 +98,7 @@ if (length($ARGV[0])>1) print " [--campaign-duplicate=1234] = duplicate check witin this campaign\n"; print " [--ignore-list=999] = ignores the list in duplicate check\n"; print " [--duplicate-list=998] = list_id that duplicate leads are moved to, default is 998\n"; + print " [--remove-old-leads] = Removes older leads, keeping the newest one\n"; print " [-h] = this help screen\n\n"; print "\n"; @@ -163,7 +165,14 @@ if (length($ARGV[0])>1) } else {$duplicatelist = '998';} - + + $remove_old_leads = 0; + if ($args =~ /--remove-old-leads/i) + { + $remove_old_leads = 1; + print "\n----- MOVE OLDER LEADS -----\n\n"; + } + } } else @@ -259,7 +268,12 @@ $b=0; foreach(@dup_list) { $dup_limit = ($dup_count[$b] - 1); - $stmtA = "select lead_id,list_id,entry_date from vicidial_list where phone_number='$dup_list[$b]' $and $campSQL $listSQL order by entry_date;"; + $descSQL = ''; + if ( $remove_old_leads ) + { + $descSQL = 'desc'; + } + $stmtA = "select lead_id,list_id,entry_date from vicidial_list where phone_number='$dup_list[$b]' $and $campSQL $listSQL order by entry_date $descSQL;"; if($DBX){print STDERR "\n|$stmtA|\n";} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr;