From 28827f1caeec5548818d06f43669aa0025098213 Mon Sep 17 00:00:00 2001 From: HB9HIL <80885850+HB9HIL@users.noreply.github.com> Date: Sun, 15 Sep 2024 20:36:22 +0000 Subject: [PATCH 1/5] set qrz to modified --- application/models/Logbookadvanced_model.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/application/models/Logbookadvanced_model.php b/application/models/Logbookadvanced_model.php index 97f129268..010b2214c 100644 --- a/application/models/Logbookadvanced_model.php +++ b/application/models/Logbookadvanced_model.php @@ -531,6 +531,14 @@ class Logbookadvanced_model extends CI_Model { $updatedData['COL_ITUZ'] = $callbook['ituz']; } + //Also set QRZ.com status to modified + if (!$this->load->is_loaded('logbook_model')) { + $this->load->model('logbook_model'); + } + if($this->logbook_model->exists_qrz_api_key($qso['station_id']) && !empty($qso['COL_QRZCOM_QSO_UPLOAD_DATE'])) { + $updatedData['COL_QRZCOM_QSO_UPLOAD_STATUS'] = 'M'; + } + if (count($updatedData) > 0) { $this->db->where('COL_PRIMARY_KEY', $qsoID); $this->db->update($this->config->item('table_name'), $updatedData); From 1083f6379c883f12706884ef3e3ea6e89ab93891 Mon Sep 17 00:00:00 2001 From: HB9HIL Date: Mon, 16 Sep 2024 01:49:34 +0200 Subject: [PATCH 2/5] also on lba edit (with load reduction) --- application/models/Logbookadvanced_model.php | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/application/models/Logbookadvanced_model.php b/application/models/Logbookadvanced_model.php index 010b2214c..ac436267c 100644 --- a/application/models/Logbookadvanced_model.php +++ b/application/models/Logbookadvanced_model.php @@ -758,6 +758,30 @@ class Logbookadvanced_model extends CI_Model { $query = $this->db->query($sql, array($value, json_decode($ids, true), $this->session->userdata('user_id'))); } + //Also set QRZ.com status to modified + if (!$this->load->is_loaded('logbook_model')) { + $this->load->model('logbook_model'); + } + $checked_stations = array(); + foreach (json_decode($ids, true) as $id) { + $qso = $this->logbook_model->get_qso($id)->row(); + + if (!isset($checked_stations[$qso->station_id])) { + $station_has_key = !empty($this->logbook_model->exists_qrz_api_key($qso->station_id)); + $checked_stations[$qso->station_id] = $station_has_key; + log_message('error', 'Checked station: ' . $qso->station_id . ' and has key: ' . $station_has_key); + } else { + $station_has_key = $checked_stations[$qso->station_id]; + log_message('error', 'Station was already checked: ' . $qso->station_id . ' and has key: ' . $station_has_key); + } + + if ($station_has_key && !empty($qso->COL_QRZCOM_QSO_UPLOAD_DATE)) { + $sql = "UPDATE ".$this->config->item('table_name')." JOIN station_profile ON ".$this->config->item('table_name').".station_id = station_profile.station_id SET " . $this->config->item('table_name').".COL_QRZCOM_QSO_UPLOAD_STATUS = 'M' WHERE " . $this->config->item('table_name').".col_primary_key in ? and station_profile.user_id = ?"; + + $query = $this->db->query($sql, array(json_decode($ids, true), $this->session->userdata('user_id'))); + } + } + $this->db->trans_complete(); return array('message' => 'OK'); From 67058cc203190738ed641086e9799f68cf68ae6e Mon Sep 17 00:00:00 2001 From: HB9HIL Date: Mon, 16 Sep 2024 10:30:40 +0200 Subject: [PATCH 3/5] easier approach --- application/models/Logbookadvanced_model.php | 34 +++++++++----------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/application/models/Logbookadvanced_model.php b/application/models/Logbookadvanced_model.php index ac436267c..debe810b3 100644 --- a/application/models/Logbookadvanced_model.php +++ b/application/models/Logbookadvanced_model.php @@ -496,8 +496,10 @@ class Logbookadvanced_model extends CI_Model { public function updateQsoWithCallbookInfo($qsoID, $qso, $callbook) { $updatedData = array(); + $updated = false; if (!empty($callbook['name']) && empty($qso['COL_NAME'])) { $updatedData['COL_NAME'] = $callbook['name']; + $updated = true; } if (!empty($callbook['gridsquare']) && empty($qso['COL_GRIDSQUARE']) && empty($qso['COL_VUCC_GRIDS'] )) { if (strpos(trim($callbook['gridsquare']), ',') === false) { @@ -505,37 +507,43 @@ class Logbookadvanced_model extends CI_Model { } else { $updatedData['COL_VUCC_GRIDS'] = strtoupper(trim($callbook['gridsquare'])); } + $updated = true; } if (!empty($callbook['city']) && empty($qso['COL_QTH'])) { $updatedData['COL_QTH'] = $callbook['city']; + $updated = true; } if (!empty($callbook['lat']) && empty($qso['COL_LAT'])) { $updatedData['COL_LAT'] = substr(($callbook['lat'] ?? ''),0,11); + $updated = true; } if (!empty($callbook['long']) && empty($qso['COL_LON'])) { $updatedData['COL_LON'] = substr(($callbook['long'] ?? ''),0,11); + $updated = true; } if (!empty($callbook['iota']) && empty($qso['COL_IOTA'])) { $updatedData['COL_IOTA'] = $callbook['iota']; + $updated = true; } if (!empty($callbook['state']) && empty($qso['COL_STATE'])) { $updatedData['COL_STATE'] = $callbook['state']; + $updated = true; } if (!empty($callbook['us_county']) && empty($qso['COL_CNTY'])) { $updatedData['COL_CNTY'] = $callbook['state'].','.$callbook['us_county']; + $updated = true; } if (!empty($callbook['qslmgr']) && empty($qso['COL_QSL_VIA'])) { $updatedData['COL_QSL_VIA'] = $callbook['qslmgr']; + $updated = true; } if (!empty($callbook['ituz']) && empty($qso['COL_ITUZ'])) { $updatedData['COL_ITUZ'] = $callbook['ituz']; + $updated = true; } //Also set QRZ.com status to modified - if (!$this->load->is_loaded('logbook_model')) { - $this->load->model('logbook_model'); - } - if($this->logbook_model->exists_qrz_api_key($qso['station_id']) && !empty($qso['COL_QRZCOM_QSO_UPLOAD_DATE'])) { + if($updated == true && $qso['COL_QRZCOM_QSO_UPLOAD_STATUS'] == 'Y') { $updatedData['COL_QRZCOM_QSO_UPLOAD_STATUS'] = 'M'; } @@ -762,23 +770,13 @@ class Logbookadvanced_model extends CI_Model { if (!$this->load->is_loaded('logbook_model')) { $this->load->model('logbook_model'); } - $checked_stations = array(); foreach (json_decode($ids, true) as $id) { $qso = $this->logbook_model->get_qso($id)->row(); - - if (!isset($checked_stations[$qso->station_id])) { - $station_has_key = !empty($this->logbook_model->exists_qrz_api_key($qso->station_id)); - $checked_stations[$qso->station_id] = $station_has_key; - log_message('error', 'Checked station: ' . $qso->station_id . ' and has key: ' . $station_has_key); - } else { - $station_has_key = $checked_stations[$qso->station_id]; - log_message('error', 'Station was already checked: ' . $qso->station_id . ' and has key: ' . $station_has_key); - } - - if ($station_has_key && !empty($qso->COL_QRZCOM_QSO_UPLOAD_DATE)) { - $sql = "UPDATE ".$this->config->item('table_name')." JOIN station_profile ON ".$this->config->item('table_name').".station_id = station_profile.station_id SET " . $this->config->item('table_name').".COL_QRZCOM_QSO_UPLOAD_STATUS = 'M' WHERE " . $this->config->item('table_name').".col_primary_key in ? and station_profile.user_id = ?"; + if ($qso->COL_QRZCOM_QSO_UPLOAD_STATUS == 'Y') { + log_message('info', '[LBA] Updating QRZ.com status for QSO ID: ' . $id . ' to M'); + $sql = "UPDATE ".$this->config->item('table_name')." JOIN station_profile ON ".$this->config->item('table_name').".station_id = station_profile.station_id SET " . $this->config->item('table_name').".COL_QRZCOM_QSO_UPLOAD_STATUS = 'M' WHERE " . $this->config->item('table_name').".col_primary_key = ? and station_profile.user_id = ?"; - $query = $this->db->query($sql, array(json_decode($ids, true), $this->session->userdata('user_id'))); + $query = $this->db->query($sql, array($id, $this->session->userdata('user_id'))); } } From 874c336f884a6a44e98850e964fbbb5c53b09aa4 Mon Sep 17 00:00:00 2001 From: HB9HIL Date: Mon, 16 Sep 2024 10:30:50 +0200 Subject: [PATCH 4/5] fix some minor error messages --- application/views/logbookadvanced/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/views/logbookadvanced/index.php b/application/views/logbookadvanced/index.php index 30fba0bca..21581a4ec 100644 --- a/application/views/logbookadvanced/index.php +++ b/application/views/logbookadvanced/index.php @@ -190,7 +190,7 @@ $options = json_decode($options); $mode) { - ?> @@ -201,7 +201,7 @@ $options = json_decode($options); From 91febd5858d6d771a5d8bc060bce9187df58126d Mon Sep 17 00:00:00 2001 From: HB9HIL Date: Mon, 16 Sep 2024 10:39:38 +0200 Subject: [PATCH 5/5] make it faster with a batch processing --- application/models/Logbookadvanced_model.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/application/models/Logbookadvanced_model.php b/application/models/Logbookadvanced_model.php index debe810b3..0d0fce919 100644 --- a/application/models/Logbookadvanced_model.php +++ b/application/models/Logbookadvanced_model.php @@ -770,16 +770,21 @@ class Logbookadvanced_model extends CI_Model { if (!$this->load->is_loaded('logbook_model')) { $this->load->model('logbook_model'); } + $modifiedQsos=[]; foreach (json_decode($ids, true) as $id) { $qso = $this->logbook_model->get_qso($id)->row(); if ($qso->COL_QRZCOM_QSO_UPLOAD_STATUS == 'Y') { log_message('info', '[LBA] Updating QRZ.com status for QSO ID: ' . $id . ' to M'); - $sql = "UPDATE ".$this->config->item('table_name')." JOIN station_profile ON ".$this->config->item('table_name').".station_id = station_profile.station_id SET " . $this->config->item('table_name').".COL_QRZCOM_QSO_UPLOAD_STATUS = 'M' WHERE " . $this->config->item('table_name').".col_primary_key = ? and station_profile.user_id = ?"; - - $query = $this->db->query($sql, array($id, $this->session->userdata('user_id'))); + $modifiedQsos[] = $id; } } + if (!empty($modifiedQsos)) { + $qso_ids = implode(',', $modifiedQsos); + $sql = "UPDATE ".$this->config->item('table_name')." JOIN station_profile ON ".$this->config->item('table_name').".station_id = station_profile.station_id SET " . $this->config->item('table_name').".COL_QRZCOM_QSO_UPLOAD_STATUS = 'M' WHERE " . $this->config->item('table_name').".col_primary_key in (".$qso_ids.") and station_profile.user_id = ?"; + $query = $this->db->query($sql, $this->session->userdata('user_id')); + } + $this->db->trans_complete(); return array('message' => 'OK');