X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2Fbin%2Ffreeside-cdrrewrited;h=846b0b976cc485f9c2e1a2f882d5d3bcac103b95;hb=c4b71bc4459cb7d403cbebede470aeb2c6292a6e;hp=09a2643e5d80527d257f2cec3df6e50aa9fe7a3c;hpb=c0e4e71f6e2888fe83c6b288a84dcc4a4897c848;p=freeside.git diff --git a/FS/bin/freeside-cdrrewrited b/FS/bin/freeside-cdrrewrited index 09a2643e5..846b0b976 100644 --- a/FS/bin/freeside-cdrrewrited +++ b/FS/bin/freeside-cdrrewrited @@ -42,13 +42,14 @@ while (1) { # instead of just doing this search like normal CDRs #hmm :/ - my @recent = grep { ($accountcode_unmatch{$_} + $accountcode_retry) < time } + my @recent = grep { ($accountcode_unmatch{$_} + $accountcode_retry) > time } keys %accountcode_unmatch; my $extra_sql = scalar(@recent) - ? ' AND acctid NOT IN (', join(',', @recent). ') ' + ? ' AND acctid NOT IN ('. join(',', @recent). ') ' : ''; my $found = 0; + my %skip = (); foreach my $cdr ( qsearch( { 'table' => 'cdr', @@ -61,6 +62,8 @@ while (1) { } ) ) { + next if $skip{$cdr->acctid}; + $found = 1; my @status = (); @@ -106,8 +109,10 @@ while (1) { my $cantfind = "can't find primary CDR with session ". $cdr->sessionnum. ", src ". $cdr->subscriber; if ( $cdr->calldate_unix + $accountcode_giveup < time ) { + warn "ERROR: $cantfind; giving up\n"; push @status, 'taqua-accountcode-NOTFOUND'; $cdr->status('done'); #so it doesn't try to rate + delete $accountcode_unmatch{$cdr->acctid}; #so it doesn't suck mem } else { warn "WARNING: $cantfind; will keep trying\n"; $accountcode_unmatch{$cdr->acctid} = time; @@ -123,6 +128,7 @@ while (1) { warn "WARNING: error rewriting primary CDR (will retry): $error\n"; next; } + $skip{$primary->acctid} = 1; push @status, 'taqua-accountcode'; $cdr->status('done'); #so it doesn't try to rate