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) { ?> -
- count; ?> - count > 0) { ?> -
- - - -
- count; ?> - count > 0) { ?> -
- - -
- count; ?> - count > 0) { ?> -
- -
@@ -146,7 +102,7 @@ function check_dxcc($result, $custom_date_format) { ?> - + diff --git a/application/views/logbookadvanced/showUpdateResult.php b/application/views/logbookadvanced/showUpdateResult.php index 987ce22b0..f5836839e 100644 --- a/application/views/logbookadvanced/showUpdateResult.php +++ b/application/views/logbookadvanced/showUpdateResult.php @@ -1,9 +1,6 @@ ' . __("Results for DXCC update:") . ''; - if ($result['count'] == 0) { - if ($all == 'false') { - echo ''; - } else { - echo ''; - } - } else { - if ($all == 'false') { - echo ''; - } else { - echo ''; - } - } - - if ($result) { - $details = []; - foreach ($result as $r) { - if (is_array($r)) { - $details[] = $r; - } - } - - if (!empty($details)) { ?> - -
- - - - - - - - - - - - - - - - - - - -
-
- ' . __("Results for state update:") . ''; if ($result['count'] == 0) { @@ -136,16 +75,6 @@ function showDistanceUpdateResult($result) { echo ''; } -function showCqzoneUpdateResult($result) { - echo '
' . __("Results for CQ zone update:") . '
'; - echo ''; -} - -function showItuzoneUpdateResult($result) { - echo '
' . __("Results for ITU zone update:") . '
'; - echo ''; -} - function showGridUpdateResult($result) { echo '
' . __("Results for gridsquare update:") . '
'; echo ''; diff --git a/assets/js/sections/logbookadvanced.js b/assets/js/sections/logbookadvanced.js index 03819b231..f0bab2bc5 100644 --- a/assets/js/sections/logbookadvanced.js +++ b/assets/js/sections/logbookadvanced.js @@ -2061,39 +2061,6 @@ function saveOptions() { }); } - function checkMissingDxcc() { - $('#checkMissingDxccsBtn').prop("disabled", true).addClass("running"); - $('#closeButton').prop("disabled", true); - - $.ajax({ - url: base_url + 'index.php/logbookadvanced/checkDb', - data: { - type: 'checkmissingdxcc' - }, - type: 'POST', - success: function(response) { - $('#checkMissingDxccsBtn').prop("disabled", false).removeClass("running"); - $('#closeButton').prop("disabled", false); - $('.result').html(response); - }, - error: function(xhr, status, error) { - $('#checkMissingDxccsBtn').prop('disabled', false).text(''); - $('#closeButton').prop('disabled', false); - - let errorMsg = 'Error checking DXCC information'; - if (xhr.responseJSON && xhr.responseJSON.message) { - errorMsg += ': ' + xhr.responseJSON.message; - } - - BootstrapDialog.alert({ - title: 'Error', - message: errorMsg, - type: BootstrapDialog.TYPE_DANGER - }); - } - }); - } - function checkFixContinent() { $('#checkFixContinentBtn').prop("disabled", true).addClass("running"); $('#closeButton').prop("disabled", true); @@ -2285,65 +2252,6 @@ function saveOptions() { }); } - function fixMissingDxcc(all) { - if (all === true) { - $('#updateDxccBtn').prop("disabled", true).addClass("running"); - BootstrapDialog.confirm({ - title: lang_general_word_danger, - message: lang_gen_advanced_logbook_confirm_fix_missing_dxcc, - type: BootstrapDialog.TYPE_DANGER, - closable: true, - draggable: true, - btnOKClass: 'btn-danger', - callback: function(result) { - if(result) { - $('#closeButton').prop("disabled", true); - $.ajax({ - url: base_url + 'index.php/logbookadvanced/fixMissingDxcc', - type: 'post', - data: { - all: all - }, - success: function(data) { - $('#updateDxccBtn').prop("disabled", false).removeClass("running"); - $('#closeButton').prop("disabled", false); - $('.result').html(data); - }, - error: function(xhr, status, error) { - $('#updateDxccBtn').prop("disabled", false).removeClass("running"); - $('#closeButton').prop("disabled", false); - $('.result').html(error); - } - }) - } else { - $('#updateDxccBtn').prop("disabled", false).removeClass("running"); - } - - }, - }); - } else { - $('#fixMissingDxccBtn').prop("disabled", true).addClass("running"); - $('#closeButton').prop("disabled", true); - $.ajax({ - url: base_url + 'index.php/logbookadvanced/fixMissingDxcc', - type: 'post', - data: { - all: all - }, - success: function(data) { - $('#fixMissingDxccBtn').prop("disabled", false).removeClass("running"); - $('#closeButton').prop("disabled", false); - $('.result').html(data); - }, - error: function(xhr, status, error) { - $('#fixMissingDxccBtn').prop("disabled", false).removeClass("running"); - $('#closeButton').prop("disabled", false); - $('.result').html(error); - } - }) - } - } - function runUpdateDistancesFix(dialogItself) { $('#updateDistanceButton').prop("disabled", true).addClass("running"); $('#closeButton').prop("disabled", true); @@ -2369,40 +2277,6 @@ function saveOptions() { }); } - function openMissingDxccList() { - $('#openMissingDxccListBtn').prop("disabled", true).addClass("running"); - - $.ajax({ - url: base_url + 'index.php/logbookadvanced/openMissingDxccList', - type: 'post', - success: function (response) { - $('#openMissingDxccListBtn').prop("disabled", false).removeClass("running"); - BootstrapDialog.show({ - title: 'QSO List', - size: BootstrapDialog.SIZE_WIDE, - cssClass: 'options', - nl2br: false, - message: response, - buttons: [ - { - label: lang_admin_close, - cssClass: 'btn-sm btn-secondary', - id: 'closeButton', - action: function (dialogItself) { - dialogItself.close(); - } - }], - onhide: function(dialogRef){ - return; - }, - }); - }, - error: function () { - $('#openMissingDxccListBtn').prop("disabled", false).removeClass("running"); - } - }); - } - function runContinentFix(dialogItself) { $('#updateContinentButton').prop("disabled", true).addClass("running"); $('#closeButton').prop("disabled", true); @@ -2425,50 +2299,6 @@ function saveOptions() { }); } - function fixMissingCqZones() { - $('#updateCqZonesBtn').prop("disabled", true).addClass("running"); - $('#closeButton').prop("disabled", true); - $.ajax({ - url: base_url + 'index.php/logbookadvanced/batchFix', - data: { - type: 'cqzones' - }, - type: 'POST', - success: function (response) { - $('#updateCqZonesBtn').prop("disabled", false).removeClass("running"); - $('#closeButton').prop("disabled", false); - $('.result').html(response); - }, - error: function(xhr, status, error) { - $('#updateCqZonesBtn').prop("disabled", false).removeClass("running"); - $('#closeButton').prop("disabled", false); - $('.result').html(error); - } - }); - } - - function fixMissingItuZones() { - $('#updateItuZonesBtn').prop("disabled", true).addClass("running"); - $('#closeButton').prop("disabled", true); - $.ajax({ - url: base_url + 'index.php/logbookadvanced/batchFix', - data: { - type: 'ituzones' - }, - type: 'POST', - success: function (response) { - $('#updateItuZonesBtn').prop("disabled", false).removeClass("running"); - $('#closeButton').prop("disabled", false); - $('.result').html(response); - }, - error: function(xhr, status, error) { - $('#updateItuZonesBtn').prop("disabled", false).removeClass("running"); - $('#closeButton').prop("disabled", false); - $('.result').html(error); - } - }); - } - function checkGrids() { $('#checkGridsBtn').prop("disabled", true).addClass("running"); $('#closeButton').prop("disabled", true); @@ -2532,7 +2362,7 @@ function saveOptions() { $('#dxccCheckTable').DataTable({ "pageLength": 25, responsive: false, - ordering: false, + ordering: true, "scrollY": "510px", "scrollCollapse": true, "paging": false,