From 0f84f71b7e07b443f7c156aa914514ba70640419 Mon Sep 17 00:00:00 2001 From: phl0 Date: Thu, 9 Feb 2023 12:12:54 +0100 Subject: [PATCH] Sort SAT amd mode stats by count DESC --- application/controllers/Statistics.php | 1 + application/models/Logbook_model.php | 1 + 2 files changed, 2 insertions(+) diff --git a/application/controllers/Statistics.php b/application/controllers/Statistics.php index 9d187b13..e34801ef 100644 --- a/application/controllers/Statistics.php +++ b/application/controllers/Statistics.php @@ -104,6 +104,7 @@ class Statistics extends CI_Controller { $modestats[$i++]['total'] = $this->logbook_model->total_fm(); $modestats[$i]['mode'] = 'digi'; $modestats[$i]['total'] = $this->logbook_model->total_digi(); + usort($modestats, fn($a, $b) => $b['total'] <=> $a['total']); header('Content-Type: application/json'); diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 1ca2f4da..919cb224 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -1624,6 +1624,7 @@ class Logbook_model extends CI_Model { $this->db->where_in('station_id', $logbooks_locations_array); $this->db->where('COL_SAT_NAME is not null'); $this->db->where('COL_SAT_NAME !=', ''); + $this->db->order_by('count DESC'); $this->db->group_by('COL_SAT_NAME'); $query = $this->db->get($this->config->item('table_name'));