RT#18834: Cacti integration [added graph generation]
[freeside.git] / bin / fix-dup-rate_prefix
1 #!/usr/bin/perl
2
3 use FS::UID qw(adminsuidsetup);
4 use FS::Record qw(qsearch);
5 use FS::rate_prefix;
6
7 adminsuidsetup shift;
8
9 #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;
10
11 foreach my $dup (
12   qsearch({
13     'select' => 'DISTINCT ON ( countrycode, npa ) *',
14     'table'  => 'rate_prefix',
15     '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 ) ) )',
16   })
17
18 ) {
19
20   my @all = qsearch('rate_prefix', { map { $_=>$dup->$_() } qw( countrycode npa ) } );
21
22   my $first = shift(@all);
23
24   foreach my $extra (@all) {
25
26     
27
28   }
29
30 }