From: Ivan Kohler Date: Mon, 20 Feb 2012 02:24:02 +0000 (-0800) Subject: adding some old random tools from the CVS tree X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=65326fcac5b2de80d211df3fc160745fb2f46b9b adding some old random tools from the CVS tree --- diff --git a/bin/fix-dup-rate_prefix b/bin/fix-dup-rate_prefix new file mode 100755 index 000000000..c6a455798 --- /dev/null +++ b/bin/fix-dup-rate_prefix @@ -0,0 +1,30 @@ +#!/usr/bin/perl + +use FS::UID qw(adminsuidsetup); +use FS::Record qw(qsearch); +use FS::rate_prefix; + +adminsuidsetup shift; + +#select * from rate_prefix where 1 < ( select count(*) from rate_prefix as other where rate_prefix.countrycode = other.countrycode and ( rate_prefix.npa = other.npa or ( rate_prefix.npa is null and other.npa is null ) ) ) order by countrycode, npa; + +foreach my $dup ( + qsearch({ + 'select' => 'DISTINCT ON ( countrycode, npa ) *', + 'table' => 'rate_prefix', + 'extra_sql' => ' where 1 < ( select count(*) from rate_prefix as other where rate_prefix.countrycode = other.countrycode and ( rate_prefix.npa = other.npa or ( rate_prefix.npa is null and other.npa is null ) ) )', + }) + +) { + + my @all = qsearch('rate_prefix', { map { $_=>$dup->$_() } qw( countrycode npa ) } ); + + my $first = shift(@all); + + foreach my $extra (@all) { + + + + } + +}