From 22bef0d504819f83fc8ec4c710b643645931272e Mon Sep 17 00:00:00 2001 From: int2001 Date: Wed, 15 Jan 2025 12:22:58 +0000 Subject: [PATCH] Fix QRZ LastQSL-Logic --- application/controllers/Qrz.php | 2 +- application/models/Logbook_model.php | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/application/controllers/Qrz.php b/application/controllers/Qrz.php index 1f2c18888..faf43e31a 100644 --- a/application/controllers/Qrz.php +++ b/application/controllers/Qrz.php @@ -312,7 +312,7 @@ class Qrz extends CI_Controller { if ((($user_id_to_load != null) && ($user_id_to_load != $station->user_id))) { // Skip User if we're called with a specific user_id continue; } - if ($lastqrz == null) { + if (($lastqrz == null) || ($user_id_to_load == null)) { $lastqrz = $this->logbook_model->qrz_last_qsl_date($station->user_id); } $qrz_api_key = $station->qrzapikey; diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 861720412..1262fa466 100644 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -3754,12 +3754,15 @@ class Logbook_model extends CI_Model { } function qrz_last_qsl_date($user_id) { - $sql = "SELECT date_format(MAX(COALESCE(COL_QRZCOM_QSO_DOWNLOAD_DATE, str_to_date('1900-01-01','%Y-%m-%d'))),'%Y-%m-%d') MAXDATE + $sql = "SELECT date_format(MAX(COALESCE(COL_QRZCOM_QSO_DOWNLOAD_DATE, str_to_date('1900-01-01','%Y-%m-%d'))),'%Y-%m-%d') MAXDATE, COUNT(1) as QSOs FROM " . $this->config->item('table_name') . " INNER JOIN station_profile ON (" . $this->config->item('table_name') . ".station_id = station_profile.station_id) WHERE station_profile.user_id=? and station_profile.qrzapikey is not null and COL_QRZCOM_QSO_DOWNLOAD_DATE is not null"; - $query = $this->db->query($sql, $user_id); + $query = $this->db->query($sql, array($user_id)); $row = $query->row(); - if (isset($row) && ($row->MAXDATE ?? '' != '')) { + if (isset($row) && (($row->QSOS ?? 0) == 0)) { // Abort / Set LASTQSO to future if no QSO is in Log to prevent processing QRZ-Data + return '2999-12-31'; + } + if (isset($row) && (($row->MAXDATE ?? '') != '')) { return $row->MAXDATE; } else { return '1900-01-01';