MT#13001 add config QUOTES and use single quotes as default

- use quotes on reseller too

Change-Id: I60dcb8ce6f63c0da3ceac46e7915d9adde468211
changes/49/1849/4
Victor Seva 11 years ago
parent c68acd8e08
commit 08330e4439

@ -53,7 +53,8 @@ my %config = (
'default.TRANSFER_PORT' => 22,
'default.TRANSFER_USER' => "cdrexport",
'default.TRANSFER_KEY' => "/root/.ssh/id_rsa",
'default.TRANSFER_REMOTE' => "/home/jail/home/cdrexport"
'default.TRANSFER_REMOTE' => "/home/jail/home/cdrexport",
'default.QUOTES' => "'"
);
sub DEBUG {

@ -16,6 +16,8 @@ PREFIX=ngcp
VERSION=007
MAX_ROWS_PER_FILE=5000
QUOTES="'"
EXPORT_INCOMING=no
ADMIN_EXPORT_FIELDS = 'accounting.cdr.id', 'accounting.cdr.update_time', 'accounting.cdr.source_user_id', 'accounting.cdr.source_provider_id', 'accounting.cdr.source_external_subscriber_id', 'source_voip_subscribers.id', 'accounting.cdr.source_external_contract_id', 'accounting.cdr.source_account_id', 'accounting.cdr.source_user', 'accounting.cdr.source_domain', 'accounting.cdr.source_cli', 'accounting.cdr.source_clir', 'accounting.cdr.source_ip', 'accounting.cdr.destination_user_id', 'accounting.cdr.destination_provider_id', 'accounting.cdr.destination_external_subscriber_id', 'destination_voip_subscribers.id', 'accounting.cdr.destination_external_contract_id', 'accounting.cdr.destination_account_id', 'accounting.cdr.destination_user', 'accounting.cdr.destination_domain', 'accounting.cdr.destination_user_in', 'accounting.cdr.destination_domain_in', 'accounting.cdr.destination_user_dialed', 'accounting.cdr.peer_auth_user', 'accounting.cdr.peer_auth_realm', 'accounting.cdr.call_type', 'accounting.cdr.call_status', 'accounting.cdr.call_code', 'CONCAT(FROM_UNIXTIME(accounting.cdr.init_time), ".", SUBSTRING_INDEX(accounting.cdr.init_time, ".", -1))', 'CONCAT(FROM_UNIXTIME(accounting.cdr.start_time), ".", SUBSTRING_INDEX(accounting.cdr.start_time, ".", -1))', 'accounting.cdr.duration', 'accounting.cdr.call_id', 'accounting.cdr.rating_status', 'accounting.cdr.rated_at', 'accounting.cdr.source_carrier_cost', 'accounting.cdr.source_customer_cost', 'COALESCE(source_carrier_bbz.zone, "onnet")', 'source_customer_bbz.zone', 'COALESCE(source_carrier_bbz.detail, "platform internal")', 'source_customer_bbz.detail', 'accounting.cdr.source_carrier_free_time', 'accounting.cdr.source_customer_free_time', 'accounting.cdr.destination_carrier_cost', 'accounting.cdr.destination_customer_cost', 'destination_carrier_bbz.zone', 'destination_customer_bbz.zone', 'destination_carrier_bbz.detail', 'destination_customer_bbz.detail', 'accounting.cdr.destination_carrier_free_time', 'accounting.cdr.destination_customer_free_time', 'accounting.cdr.source_reseller_cost', 'source_reseller_bbz.zone', 'source_reseller_bbz.detail', 'accounting.cdr.source_reseller_free_time', 'accounting.cdr.destination_reseller_cost', 'destination_reseller_bbz.zone', 'destination_reseller_bbz.detail', 'accounting.cdr.destination_reseller_free_time'

@ -51,14 +51,14 @@ my @ids;
sub callback {
my ($row, $res_row) = @_;
my $quotes = NGCP::CDR::Exporter::confval('QUOTES');
my @fields = @{ $row };
my $id = shift @fields;
my $src_uuid = shift @fields;
my $dst_uuid = shift @fields;
my $src_provid = shift @fields;
my $dst_provid = shift @fields;
@fields = map { defined $_ ? "'$_'" : "''" } (@fields);
@fields = map { defined $_ ? $quotes . $_ . $quotes : $quotes. $quotes } (@fields);
if(confval('EXPORT_INCOMING') eq "no" && $src_uuid eq "0") {
push @ignored_ids, $id;
@ -69,7 +69,7 @@ sub callback {
write_reseller('system', $line);
push(@ids, $id);
my $reseller_line = join ",", @$res_row;
my $reseller_line = join ",", map { defined $_ ? $quotes . $_ . $quotes : $quotes. $quotes } (@$res_row);
if($src_uuid ne "0") {
write_reseller_id($src_provid, $reseller_line);

@ -20,6 +20,8 @@ PREFIX=sipwise
VERSION=001
SUFFIX=edr
QUOTES="'"
# none if no remote transfer should be done
# other options are sftp (requiring TRANSFER_PASS)
# or sftp-sh (requiring TRANSFER_KEY)

@ -52,12 +52,12 @@ NGCP::CDR::Exporter::run(\&callback);
sub callback {
my ($row, $res_row) = @_;
my $quotes = NGCP::CDR::Exporter::confval('QUOTES');
my @head = @{ $row }[0 .. 5];
my ($id, $sub_id, $res_id, $type, $old, $new) = @head;
my @fields = map { defined $_ ? "\"$_\"" : '""' } (@{ $row }[6 .. @{ $row }-1]);
my @fields = map {defined $_ ? $quotes . $_ . $quotes : $quotes. $quotes } (@{ $row }[6 .. @{ $row }-1]);
my $line = join ",", @fields;
my $reseller_line = join ",", @$res_row;
my $reseller_line = join ",", map {defined $_ ? $quotes . $_ . $quotes : $quotes. $quotes }(@$res_row);
if(confval('FILTER_FLAPPING')) {
if($type =~ /^start_(.+)$/) {

Loading…
Cancel
Save