From b5272984d1bce21497f5b27b982b521a2312c79c Mon Sep 17 00:00:00 2001 From: demonspork Date: Sat, 20 Feb 2021 11:14:47 -0600 Subject: [PATCH] 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. --- app/xml_cdr/resources/classes/xml_cdr.php | 10 ++++++++-- app/xml_cdr/xml_cdr_inc.php | 10 +++++----- app/xml_cdr/xml_cdr_statistics_inc.php | 8 ++++---- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/app/xml_cdr/resources/classes/xml_cdr.php b/app/xml_cdr/resources/classes/xml_cdr.php index 20a6d6fa25..a8675eb507 100644 --- a/app/xml_cdr/resources/classes/xml_cdr.php +++ b/app/xml_cdr/resources/classes/xml_cdr.php @@ -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) { diff --git a/app/xml_cdr/xml_cdr_inc.php b/app/xml_cdr/xml_cdr_inc.php index 9e34896f7d..c1151d0f07 100644 --- a/app/xml_cdr/xml_cdr_inc.php +++ b/app/xml_cdr/xml_cdr_inc.php @@ -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; diff --git a/app/xml_cdr/xml_cdr_statistics_inc.php b/app/xml_cdr/xml_cdr_statistics_inc.php index 4b1c9d9b04..e695b8e67c 100644 --- a/app/xml_cdr/xml_cdr_statistics_inc.php +++ b/app/xml_cdr/xml_cdr_statistics_inc.php @@ -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