diff options
author | ivan <ivan> | 2011-05-01 23:11:04 +0000 |
---|---|---|
committer | ivan <ivan> | 2011-05-01 23:11:04 +0000 |
commit | 9b836c9bfedd7022d22ca3f3978470a5775caa72 (patch) | |
tree | 47c9c5f4a73cf9ac237f53f36953c4aaaef5d3bc /bin | |
parent | 790db5a543f9d697ed373acab2b95566634cf029 (diff) |
cdr reimporting, RT#12181
Diffstat (limited to 'bin')
-rw-r--r-- | bin/cdr.reimport | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/bin/cdr.reimport b/bin/cdr.reimport index 51c62d2ea..fe00e4505 100644 --- a/bin/cdr.reimport +++ b/bin/cdr.reimport @@ -22,19 +22,28 @@ my($new, $rep, $skip) = (0, 0, 0); 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 ) { |