diff --git a/cdr-exporter.pl b/cdr-exporter.pl index d1485b1..4f5efa5 100755 --- a/cdr-exporter.pl +++ b/cdr-exporter.pl @@ -12,13 +12,9 @@ use NGCP::CDR::Exporter; NGCP::CDR::Exporter::get_config('exporter', 'cdr-exporter.conf'); - print("+++ Start run with DB " . (confval('DBUSER') || "(undef)") . "\@".confval('DBDB')." to ".confval('PREFIX')."\n"); - - - # add fields we definitely need, will be removed during processing unshift @NGCP::CDR::Exporter::admin_fields, qw/ accounting.cdr.id @@ -27,28 +23,21 @@ unshift @NGCP::CDR::Exporter::admin_fields, qw/ accounting.cdr.source_provider_id accounting.cdr.destination_provider_id /; + my @trailer = ( { 'order by' => 'accounting.cdr.id' }, ); +# working vars at beginning: +my @ignored_ids = (); +my @ids = (); NGCP::CDR::Exporter::prepare_dbh(\@trailer, 'accounting.cdr'); - NGCP::CDR::Exporter::prepare_output(); - - NGCP::CDR::Exporter::run(\&callback); - - - -my @ignored_ids = (); -my @ids; - - - sub filestats_callback { my ($data_row, $ref) = @_; @@ -104,14 +93,8 @@ sub callback { #DEBUG "ignoring cdr ids " . (join ",", @ignored_ids); - - - NGCP::CDR::Exporter::finish(); - - - update_export_status("accounting.cdr", \@ids, "ok"); # TODO: should be tagged as ignored/skipped/whatever update_export_status("accounting.cdr", \@ignored_ids, "ok"); diff --git a/event-exporter.pl b/event-exporter.pl index 3ecc7a7..2918a09 100755 --- a/event-exporter.pl +++ b/event-exporter.pl @@ -46,10 +46,6 @@ my @filter_ids = (); NGCP::CDR::Exporter::run(\&callback); - - - - sub callback { my ($row, $res_row) = @_; my $quotes = NGCP::CDR::Exporter::confval('QUOTES'); @@ -75,7 +71,7 @@ sub callback { my $k = "$sub_id;$t;$old"; my $ids = $filter{$k} // []; if(@{ $ids }) { - my $old_id = pop @{ $ids }; + my $old_id = pop @{ $ids }; say "... id $id is an update event of id $old_id, merge"; delete $lines{$old_id}; $res_id and delete $res_lines{$res_id}{$old_id}; @@ -97,7 +93,7 @@ sub callback { my $k = "$sub_id;$t;$old"; my $ids = $filter{$k} // []; if(@{ $ids }) { - my $old_id = pop @{ $ids }; + my $old_id = pop @{ $ids }; say "... id $id is an end event of id $old_id, filter"; push @filter_ids, ($id, $old_id); delete $lines{$old_id}; @@ -133,20 +129,13 @@ for my $res (keys(%res_lines)) { } } - - - NGCP::CDR::Exporter::finish(); - - my @ids = keys %lines; update_export_status("accounting.events", \@filter_ids, "filtered"); update_export_status("accounting.events", \@ids, "ok"); - NGCP::CDR::Exporter::commit(); - # vim: set tabstop=4 expandtab: