TT#7818 add CallLists own_cli parameter

* enables a filter for calls that were initated or received
      by the specified subscriber/custoemr
    * set direction for internal subscriber calls to "out"

Change-Id: I2f3b543b57352f92dc5a67bc82779cf371b6f23c
changes/57/11057/11
Kirill Solomko 9 years ago
parent 5ca08c3eae
commit 24ffcb618c

@ -222,6 +222,38 @@ sub query_params {
},
},
},
{
param => 'own_cli',
description => 'Filter calls by a specific number that is a part of in our out calls.',
new_rs => sub {
my ($c,$q,$rs) = @_;
my $owner = $c->stash->{owner} // {};
return unless $owner;
if ($owner->{subscriber}) {
return $rs->search_rs({
-or => [
{ source_cli => $q,
source_user_id => $owner->{subscriber}->uuid,
},
{ destination_user_in => $q,
destination_user_id => $owner->{subscriber}->uuid,
},
],
});
} elsif ($owner->{customer}) {
return $rs->search_rs({
-or => [
{ source_cli => $q,
source_account_id => $owner->{customer}->id,
},
{ destination_user_in => $q,
destination_account_id => $owner->{customer}->id,
},
],
});
}
},
},
];
}

@ -45,12 +45,18 @@ sub process_cdr_item {
$resource->{intra_customer} = JSON::false;
$intra = 0;
}
# out by default
if(defined $sub && $sub->uuid eq $item->destination_user_id) {
# internal subscriber calls => out
if(defined $sub && $sub->uuid eq $item->source_user_id &&
$sub->uuid eq $item->destination_user_id) {
$resource->{direction} = "out";
# subscriber incoming calls => in
} elsif (defined $sub && $sub->uuid eq $item->destination_user_id) {
$resource->{direction} = "in";
# customer incoming calls => in
} elsif (defined $cust && $item->destination_account_id == $cust->id
&& ( $item->source_account_id != $cust->id ) ) {
$resource->{direction} = "in";
# rest => out
} else {
$resource->{direction} = "out";
}

Loading…
Cancel
Save