From 8acccc4a829e57ee28e5c552be40b9067c9e223d Mon Sep 17 00:00:00 2001 From: Andreas Kristiansen <6977712+AndreasK79@users.noreply.github.com> Date: Fri, 24 May 2024 10:40:48 +0200 Subject: [PATCH] Decrease db queries for dashboard rendering --- application/models/Vucc.php | 23 ++++++++++--------- application/views/interface_assets/header.php | 9 ++++---- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/application/models/Vucc.php b/application/models/Vucc.php index 5ef1343fe..28dbbbb34 100644 --- a/application/models/Vucc.php +++ b/application/models/Vucc.php @@ -2,6 +2,14 @@ class VUCC extends CI_Model { + + private $logbooks_locations_array; + public function __construct() + { + $this->load->model('logbooks_model'); + $this->logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + } + /* * Fetches worked and confirmed gridsquare on each band and total */ @@ -100,15 +108,12 @@ class VUCC extends CI_Model * $confirmationMethod - qsl, lotw or both, use anything else to skip confirmed */ function get_vucc_summary_col_vucc($band, $confirmationMethod) { - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); - if (!$logbooks_locations_array) { + if (!$this->logbooks_locations_array) { return null; } - $location_list = "'".implode("','",$logbooks_locations_array)."'"; + $location_list = "'".implode("','",$this->logbooks_locations_array)."'"; $sql = "select distinct col_vucc_grids from " . $this->config->item('table_name') . @@ -144,15 +149,11 @@ class VUCC extends CI_Model * $confirmationMethod - qsl, lotw or both, use anything else to skip confirmed */ function get_vucc_summary($band, $confirmationMethod) { - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); - - if (!$logbooks_locations_array) { + if (!$this->logbooks_locations_array) { return null; } - $location_list = "'".implode("','",$logbooks_locations_array)."'"; + $location_list = "'".implode("','",$this->logbooks_locations_array)."'"; $sql = "select distinct upper(substring(log.col_gridsquare, 1, 4)) gridsquare from " . $this->config->item('table_name') . " log". diff --git a/application/views/interface_assets/header.php b/application/views/interface_assets/header.php index 60d0df9f3..43313e8b7 100644 --- a/application/views/interface_assets/header.php +++ b/application/views/interface_assets/header.php @@ -470,13 +470,13 @@ user_options_model->get_options('header_menu', array('option_name' => 'utc_headermenu'))->row()->option_value ?? 'false'); - if ($utc_headermenu == 'true') { + if ($utc_headermenu == 'true') { ?> - optionslib->get_option('menuitems'); - if ($this->optionslib->get_option('menuitems')) { ?> + if ($menuitems) { ?>