Don't filter LOSE_RACE of already filtering originating_leg_uuid

It is redundant to filter out LOSE_RACE when originating_leg_uuid is also filtered, there is an overlap where every call with LOSE_RACE also has an originating_leg.
This commit is contained in:
demonspork 2021-02-20 11:14:47 -06:00
parent 77974b71dc
commit b5272984d1
3 changed files with 17 additions and 11 deletions

View File

@ -973,7 +973,10 @@ if (!class_exists('xml_cdr')) {
$sql .= "filter ( \n";
$sql .= " where c.extension_uuid = e.extension_uuid \n";
$sql .= " and missed_call = true \n";
if (!permission_exists('xml_cdr_lose_race')) {
if (!permission_exists('xml_cdr_enterprise_leg')) {
$sql .= " and originating_leg_uuid is null \n";
}
elseif (!permission_exists('xml_cdr_lose_race')) {
$sql .= " and hangup_cause <> 'LOSE_RACE' \n";
}
if ($this->include_internal) {
@ -1029,7 +1032,10 @@ if (!class_exists('xml_cdr')) {
$sql .= "count(*) \n";
$sql .= "filter ( \n";
$sql .= " where c.extension_uuid = e.extension_uuid \n";
if (!permission_exists('xml_cdr_lose_race')) {
if (!permission_exists('xml_cdr_enterprise_leg')) {
$sql .= " and originating_leg_uuid is null \n";
}
elseif (!permission_exists('xml_cdr_lose_race')) {
$sql .= " and hangup_cause <> 'LOSE_RACE' \n";
}
if ($this->include_internal) {

View File

@ -417,9 +417,13 @@
$sql .= "and hangup_cause like :hangup_cause ";
$parameters['hangup_cause'] = '%'.$hangup_cause.'%';
}
elseif (!permission_exists('xml_cdr_lose_race')) {
elseif (!permission_exists('xml_cdr_lose_race') && permission_exists('xml_cdr_enterprise_leg')) {
$sql .= "and hangup_cause != 'LOSE_RACE' ";
}
//exclude enterprise ring group legs
if (!permission_exists('xml_cdr_enterprise_leg')) {
$sql .= "and originating_leg_uuid IS NULL ";
}
if (strlen($call_result) > 0) {
switch ($call_result) {
case 'answered':
@ -495,10 +499,6 @@
$sql .= "and leg = :leg ";
$parameters['leg'] = $leg;
}
//exclude enterprise ring group legs
if (!permission_exists('xml_cdr_enterprise_leg')) {
$sql .= "and originating_leg_uuid IS NULL ";
}
if (is_numeric($tta_min)) {
$sql .= "and (c.answer_epoch - c.start_epoch) >= :tta_min ";
$parameters['tta_min'] = $tta_min;

View File

@ -280,14 +280,14 @@
$sql_where_ands[] = "leg = :leg";
$parameters['leg'] = $leg;
}
//If you can't see lose_race, don't run stats on it
if (!permission_exists('xml_cdr_lose_race')) {
$sql_where_ands[] = "hangup_cause != 'LOSE_RACE'";
}
//Exclude enterprise ring group legs
if (!permission_exists('xml_cdr_enterprise_leg')) {
$sql_where_ands[] .= "originating_leg_uuid IS NULL";
}
//If you can't see lose_race, don't run stats on it
elseif (!permission_exists('xml_cdr_lose_race')) {
$sql_where_ands[] = "hangup_cause != 'LOSE_RACE'";
}
//if not admin or superadmin, only show own calls