From 5a39417997aa2ad5b1f87a1aee17708dd6a6a03f Mon Sep 17 00:00:00 2001 From: Andreas Kristiansen <6977712+AndreasK79@users.noreply.github.com> Date: Wed, 7 Jan 2026 11:29:15 +0100 Subject: [PATCH] [DBTools] Removed unused code + tweaks --- application/controllers/Logbookadvanced.php | 24 --- application/models/Logbookadvanced_model.php | 102 +---------- .../views/logbookadvanced/checkresult.php | 46 +---- .../logbookadvanced/showUpdateResult.php | 71 -------- assets/js/sections/logbookadvanced.js | 172 +----------------- 5 files changed, 3 insertions(+), 412 deletions(-) diff --git a/application/controllers/Logbookadvanced.php b/application/controllers/Logbookadvanced.php index 97c1e2f57..d78fb41de 100644 --- a/application/controllers/Logbookadvanced.php +++ b/application/controllers/Logbookadvanced.php @@ -895,30 +895,6 @@ class Logbookadvanced extends CI_Controller { $this->load->view('logbookadvanced/showStateQsos', $data); } - public function fixMissingDxcc() { - if(!clubaccess_check(9)) return; - - $all = $this->input->post('all', true); - $this->load->model('logbookadvanced_model'); - $result = $this->logbookadvanced_model->check_missing_dxcc_id($all); - - $data['result'] = $result; - $data['all'] = $all; - $data['type'] = 'dxcc'; - - $this->load->view('logbookadvanced/showUpdateResult', $data); - } - - public function openMissingDxccList() { - if(!clubaccess_check(9)) return; - - $this->load->model('logbookadvanced_model'); - - $data['qsos'] = $this->logbookadvanced_model->getMissingDxccQsos(); - - $this->load->view('logbookadvanced/showMissingDxccQsos', $data); - } - public function batchFix() { if(!clubaccess_check(9)) return; diff --git a/application/models/Logbookadvanced_model.php b/application/models/Logbookadvanced_model.php index 435467741..aef3c079e 100644 --- a/application/models/Logbookadvanced_model.php +++ b/application/models/Logbookadvanced_model.php @@ -1632,16 +1632,10 @@ class Logbookadvanced_model extends CI_Model { return $this->check_missing_distance(); case 'checkcontinent': return $this->check_qsos_missing_continent(); - case 'checkmissingdxcc': - return $this->check_missing_dxcc(); case 'checkdxcc': return $this->check_dxcc(); case 'checkstate': return $this->check_missing_state(); - case 'checkcqzones': - return $this->check_missing_cq_zones(); - case 'checkituzones': - return $this->check_missing_itu_zones(); case 'checkgrids': return $this->getMissingGridQsos(); case 'checkincorrectgridsquares': @@ -1696,17 +1690,6 @@ class Logbookadvanced_model extends CI_Model { return $query->result(); } - public function check_missing_dxcc() { - $sql = "select count(*) as count from " . $this->config->item('table_name') . " - join station_profile on " . $this->config->item('table_name') . ".station_id = station_profile.station_id - where user_id = ? and coalesce(col_dxcc, '') = ''"; - - $bindings[] = [$this->session->userdata('user_id')]; - - $query = $this->db->query($sql, $bindings); - return $query->result(); - } - public function check_qsos_missing_continent() { $sql = "select count(*) as count from " . $this->config->item('table_name') . " join station_profile on " . $this->config->item('table_name') . ".station_id = station_profile.station_id @@ -1755,30 +1738,6 @@ class Logbookadvanced_model extends CI_Model { return $query->result(); } - public function check_missing_cq_zones() { - $sql = "select count(*) as count from " . $this->config->item('table_name') . " - join station_profile on " . $this->config->item('table_name') . ".station_id = station_profile.station_id - join dxcc_entities on " . $this->config->item('table_name') . ".col_dxcc = dxcc_entities.adif - where user_id = ? and col_cqz is NULL"; - - $bindings[] = [$this->session->userdata('user_id')]; - - $query = $this->db->query($sql, $bindings); - return $query->result(); - } - - public function check_missing_itu_zones() { - $sql = "select count(*) as count from " . $this->config->item('table_name') . " - join station_profile on " . $this->config->item('table_name') . ".station_id = station_profile.station_id - join dxcc_entities on " . $this->config->item('table_name') . ".col_dxcc = dxcc_entities.adif - where user_id = ? and col_ituz is NULL"; - - $bindings[] = [$this->session->userdata('user_id')]; - - $query = $this->db->query($sql, $bindings); - return $query->result(); - } - /** * Fix state for a batch of QSOs using GeoJSON lookup * @@ -1894,72 +1853,12 @@ class Logbookadvanced_model extends CI_Model { return $query->result(); } - /* - This was moved from update to the advanced logbook. Maninly because it affected all QSOs in the logbook, without filters on users or stations. - We need to ensure that we only update the relevant QSOs, filtered on user. - */ - public function check_missing_dxcc_id($all = false) { - ini_set('memory_limit', '-1'); // This consumes a lot of Memory! - $this->db->trans_start(); // Transaction has to be started here, because otherwise we're trying to update rows which are locked by the select - $sql = "select COL_PRIMARY_KEY, COL_CALL, COL_TIME_ON, COL_TIME_OFF, station_profile.station_profile_name from " . $this->config->item('table_name') . - " join station_profile on " . $this->config->item('table_name') . ".station_id = station_profile.station_id - where station_profile.user_id = ?"; - - if ($all == 'false') { // check which to update - records with no dxcc or all records - $sql .= " and (COL_DXCC is NULL or COL_DXCC = '')"; - } - $r = $this->db->query($sql, array($this->session->userdata('user_id'))); - $this->load->model('logbook_model'); - - $count = 0; - if ($r->num_rows() > 0) { //query dxcc_prefixes - $sql = "update " . $this->config->item('table_name') . " set COL_COUNTRY = ?, COL_DXCC = ? where COL_PRIMARY_KEY = ?"; - $q = $this->db->conn_id->prepare($sql); // PREPARE this statement. For DB this means: No parsing overhead, parse once use many (see execute query below) - foreach ($r->result_array() as $row) { - $qso_date = $row['COL_TIME_OFF'] == '' ? $row['COL_TIME_ON'] : $row['COL_TIME_OFF']; - $qso_date = date("Y-m-d", strtotime($qso_date)); - $d = $this->logbook_model->check_dxcc_table($row['COL_CALL'], $qso_date); - if ($d[0] == 'Not Found') { - $result[] = [ - 'id' => $row['COL_PRIMARY_KEY'], - 'callsign' => $row['COL_CALL'], - 'reason' => 'DXCC Not Found', - 'location' => $row['station_profile_name'], - 'id' => $row['COL_PRIMARY_KEY'] - ]; - } else { - $q->execute(array(addslashes(ucwords(strtolower($d[1]), "- (/")), $d[0], $row['COL_PRIMARY_KEY'])); - $count++; - } - } - } - $this->db->trans_complete(); - $result['count'] = $count; - - return $result; - } - - function getMissingDxccQsos() { - $sql = "SELECT col_primary_key, col_call, col_time_on, col_mode, col_submode, col_band, col_state, col_gridsquare, d.name as dxcc_name, station_profile.station_profile_name FROM " . $this->config->item('table_name') . " qsos - JOIN station_profile ON qsos.station_id = station_profile.station_id - LEFT JOIN dxcc_entities d ON qsos.COL_DXCC = d.adif - WHERE station_profile.user_id = ? - AND (qsos.COL_DXCC IS NULL OR qsos.COL_DXCC = '') - ORDER BY COL_TIME_ON DESC"; - - $query = $this->db->query($sql, [$this->session->userdata('user_id')]); - - return $query->result(); - } - /* Function to run batch fixes on the logbook. Used in dbtools section. */ function batchFix($type) { switch ($type) { - case 'dxcc': - return $this->check_missing_dxcc_id('true'); case 'distance': return $this->update_distances_batch(); case 'continent': @@ -2041,6 +1940,7 @@ class Logbookadvanced_model extends CI_Model { Check all QSOs DXCC against current DXCC database */ public function check_dxcc() { + ini_set('memory_limit', '-1'); $i = 0; $result = array(); diff --git a/application/views/logbookadvanced/checkresult.php b/application/views/logbookadvanced/checkresult.php index 4241b51e4..1127bb0e0 100644 --- a/application/views/logbookadvanced/checkresult.php +++ b/application/views/logbookadvanced/checkresult.php @@ -8,7 +8,6 @@ if($this->session->userdata('user_date_format')) { $custom_date_format = $this->config->item('qso_date_format'); } - switch ($type) { case 'checkdistance': check_missing_distance($result); @@ -16,15 +15,6 @@ switch ($type) { case 'checkcontinent': check_qsos_missing_continent($result); break; - case 'checkmissingdxcc': - check_missing_dxcc($result); - break; - case 'checkcqzones': - check_missing_cq_zones($result); - break; - case 'checkituzones': - check_missing_itu_zones($result); - break; case 'checkgrids': check_missing_grids($result); break; @@ -77,40 +67,6 @@ function check_qsos_missing_continent($result) { ?> -