From 327fb1f4850995c53ce847dd7e6790efc5be455f Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Tue, 4 Oct 2022 20:50:14 +0200 Subject: [PATCH] [Statistics] Fix for different casing on bands and col_submode either null or blank --- application/models/Stats.php | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/application/models/Stats.php b/application/models/Stats.php index d137aa83..8fb9bf20 100644 --- a/application/models/Stats.php +++ b/application/models/Stats.php @@ -93,7 +93,8 @@ } foreach ($modeunique as $mode) { - if ($mode->col_submode == null) { + //if ($mode->col_submode == null) { + if ($mode->col_submode == null || $mode->col_submode == "") { $modecalls[$mode->col_mode] = $mode->calls; } else { $modecalls[$mode->col_submode] = $mode->calls; @@ -104,7 +105,8 @@ $workedQso = $this->getUniqueCallsigns(); foreach ($workedQso as $line) { - if ($line->col_submode == null) { + //if ($line->col_submode == null) { + if ($line->col_submode == null || $line->col_submode == "") { $qsoView [$line->col_mode] [$line->band] = $line->calls; } else { $qsoView [$line->col_submode] [$line->band] = $line->calls; @@ -130,9 +132,9 @@ $bands = array(); - $this->db->select('count(distinct col_call) as calls, col_band as band, col_mode, col_submode', FALSE); + $this->db->select('count(distinct col_call) as calls, lower(col_band) as band, col_mode, coalesce(col_submode, "") col_submode', FALSE); $this->db->where_in('station_id', $logbooks_locations_array); - $this->db->group_by('col_band, col_mode, col_submode'); + $this->db->group_by('lower(col_band), col_mode, coalesce(col_submode, "")'); $query = $this->db->get($this->config->item('table_name')); @@ -150,9 +152,9 @@ $bands = array(); - $this->db->select('count(distinct col_call) as calls, col_mode, col_submode', FALSE); + $this->db->select('count(distinct col_call) as calls, col_mode, coalesce(col_submode, "") col_submode', FALSE); $this->db->where_in('station_id', $logbooks_locations_array); - $this->db->group_by('col_mode, col_submode'); + $this->db->group_by('col_mode, coalesce(col_submode, "")'); $query = $this->db->get($this->config->item('table_name')); @@ -218,7 +220,7 @@ // Populating array with worked $workedQso = $this->modeBandQso(); foreach ($workedQso as $line) { - if ($line->col_submode == null) { + if ($line->col_submode == null || $line->col_submode == "") { $qsoView [$line->col_mode] [$line->band] = $line->count; $modetotal[$line->col_mode] += $line->count; } else { @@ -246,9 +248,9 @@ $bands = array(); - $this->db->select('count(*) as count, col_band as band, col_mode, col_submode', FALSE); + $this->db->select('count(*) as count, lower(col_band) as band, col_mode, coalesce(col_submode, "") col_submode', FALSE); $this->db->where_in('station_id', $logbooks_locations_array); - $this->db->group_by('col_band, col_mode, col_submode'); + $this->db->group_by('lower(col_band), col_mode, coalesce(col_submode, "")'); $query = $this->db->get($this->config->item('table_name')); @@ -266,7 +268,7 @@ $bands = array(); - $this->db->select('distinct col_band+0 as bandsort, col_band as band', FALSE); + $this->db->select('distinct col_band+0 as bandsort, lower(col_band) as band', FALSE); $this->db->where_in('station_id', $logbooks_locations_array); $this->db->order_by('bandsort', 'desc'); @@ -290,14 +292,14 @@ $modes = array(); - $this->db->select('distinct col_mode, col_submode', FALSE); + $this->db->select('distinct col_mode, coalesce(col_submode, "") col_submode', FALSE); $this->db->where_in('station_id', $logbooks_locations_array); $this->db->order_by('col_mode, col_submode', 'ASC'); $query = $this->db->get($this->config->item('table_name')); foreach($query->result() as $mode){ - if ($mode->col_submode == null) { + if ($mode->col_submode == null || $mode->col_submode == "") { array_push($modes, $mode->col_mode); } else { array_push($modes, $mode->col_submode);