[freeside-commits] freeside/bin cdr.reimport,1.3,1.4
Ivan,,,
ivan at wavetail.420.am
Sun May 1 16:11:06 PDT 2011
Update of /home/cvs/cvsroot/freeside/bin
In directory wavetail.420.am:/tmp/cvs-serv7590/bin
Modified Files:
cdr.reimport
Log Message:
cdr reimporting, RT#12181
Index: cdr.reimport
===================================================================
RCS file: /home/cvs/cvsroot/freeside/bin/cdr.reimport,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -w -d -r1.3 -r1.4
--- cdr.reimport 1 May 2011 20:02:38 -0000 1.3
+++ cdr.reimport 1 May 2011 23:11:04 -0000 1.4
@@ -22,19 +22,28 @@
my $cb = sub {
my($cdr, $param) = @_;
- my @exists = qsearch({
- 'table' => 'cdr',
- 'hashref' => { 'uniqueid' => $cdr->uniqueid,
- 'src' => $cdr->src,
- 'startdate' => $cdr->startdate,
- },
+ my @exists = qsearch('cdr', {
+ map { $_ => $cdr->$_() }
+ qw( uniqueid calldate src dst charged_party )
});
unless ( scalar(@exists) ) {
$new++;
return;
}
- return "too many matches found!" if scalar(@exists) > 1;
+
+ if ( scalar(@exists) == 2 ) {
+ if ( $exists[0]->freesidestatus || $exists[1]->freesidestatus ) {
+ return "processed double record for uniqueid ". $cdr->uniqueid. "\n";
+ }
+ warn "deleting double record for uniqueid ". $cdr->uniqueid. "\n";
+ my $extra = shift @exists;
+ my $error = $extra->delete;
+ return $error if $error;
+ }
+
+ return "too many matches (". scalar(@exists). ") found!"
+ if scalar(@exists) > 1;
my $exists = $exists[0];
if ( $exists->freesidestatus ) {
More information about the freeside-commits
mailing list