summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2011-05-01 23:11:05 +0000
committerivan <ivan>2011-05-01 23:11:05 +0000
commit9847c9e806e3da994387aaedca7222e412e39276 (patch)
tree005f4e91bba58852509f1d602b208f9566384b15
parenta8d6ee9aa912326566abaaf6e0ebac960a4b7217 (diff)
cdr reimporting, RT#12181
-rw-r--r--bin/cdr.reimport23
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 ) {