From 1bad73c96c95eaaaf0c9e209ad48644b3c999d79 Mon Sep 17 00:00:00 2001 From: Andreas Kristiansen <6977712+AndreasK79@users.noreply.github.com> Date: Sat, 20 Dec 2025 15:01:53 +0100 Subject: [PATCH] Updated for method comparison and dxcc fixes --- application/controllers/Calltester.php | 68 +++++++- .../views/calltester/comparison_result.php | 164 ++++++++++++++++++ application/views/calltester/index.php | 6 +- assets/js/sections/calltester.js | 7 +- src/Dxcc/Dxcc.php | 8 +- 5 files changed, 242 insertions(+), 11 deletions(-) create mode 100644 application/views/calltester/comparison_result.php diff --git a/application/controllers/Calltester.php b/application/controllers/Calltester.php index 3a1aba3b1..899aea5c5 100644 --- a/application/controllers/Calltester.php +++ b/application/controllers/Calltester.php @@ -36,13 +36,28 @@ class Calltester extends CI_Controller { $this->load->view('interface_assets/footer', $footerData); } - /* Uses DXCC Class. Much faster */ function doDxccCheck() { - $this->load->model('logbook_model'); + set_time_limit(3600); + $de = $this->input->post('de', true); + $compare = $this->input->post('compare', true); + + if ($compare == "true") { + $result = $this->doClassCheck($de); + $result2 = $this->doDxccCheckModel($de); + + return $this->compareDxccChecks($result, $result2); + } + + $result = $this->doClassCheck($de); + $this->loadView($result); + } + + /* Uses DXCC Class. Much faster */ + function doClassCheck($de) { $i = 0; $result = array(); - $callarray = $this->getQsos($this->input->post('de', true)); + $callarray = $this->getQsos($de); // Starting clock time in seconds $start_time = microtime(true); @@ -81,16 +96,16 @@ class Calltester extends CI_Controller { $data['calls_tested'] = $i; $data['result'] = $result; - $this->load->view('calltester/result', $data); + return $data; } /* Uses Logbook_model and the normal dxcc lookup, which is slow */ - function doDxccCheck2() { + function doDxccCheckModel($de) { $this->load->model('logbook_model'); $i = 0; $result = array(); - $callarray = $this->getQsos($this->input->post('de', true)); + $callarray = $this->getQsos($de); // Starting clock time in seconds $start_time = microtime(true); @@ -126,9 +141,50 @@ class Calltester extends CI_Controller { $data['calls_tested'] = $i; $data['result'] = $result; + return $data; + } + + function loadView($data) { $this->load->view('calltester/result', $data); } + function compareDxccChecks($result, $result2) { + // Convert arrays to comparable format using callsign, qso_date, and id as unique keys + $classCheckItems = []; + $modelCheckItems = []; + + // Create associative arrays for easier comparison + foreach ($result['result'] as $item) { + $key = $item['callsign'] . '|' . $item['qso_date'] . '|' . $item['id']; + $classCheckItems[$key] = $item; + } + + foreach ($result2['result'] as $item) { + $key = $item['callsign'] . '|' . $item['qso_date'] . '|' . $item['id']; + $modelCheckItems[$key] = $item; + } + + // Find items that are in class check but not in model check + $onlyInClass = array_diff_key($classCheckItems, $modelCheckItems); + + // Find items that are in model check but not in class check + $onlyInModel = array_diff_key($modelCheckItems, $classCheckItems); + + // Prepare comparison data + $comparisonData = []; + $comparisonData['class_execution_time'] = $result['execution_time']; + $comparisonData['model_execution_time'] = $result2['execution_time']; + $comparisonData['class_calls_tested'] = $result['calls_tested']; + $comparisonData['model_calls_tested'] = $result2['calls_tested']; + $comparisonData['class_total_issues'] = count($result['result']); + $comparisonData['model_total_issues'] = count($result2['result']); + $comparisonData['only_in_class'] = $onlyInClass; + $comparisonData['only_in_model'] = $onlyInModel; + $comparisonData['common_issues'] = array_intersect_key($classCheckItems, $modelCheckItems); + + $this->load->view('calltester/comparison_result', $comparisonData); + } + function getQsos($station_id) { $sql = 'select distinct col_country, col_call, col_dxcc, date(col_time_on) date, station_profile.station_profile_name, col_primary_key from ' . $this->config->item('table_name') . ' diff --git a/application/views/calltester/comparison_result.php b/application/views/calltester/comparison_result.php new file mode 100644 index 000000000..c6b3abab6 --- /dev/null +++ b/application/views/calltester/comparison_result.php @@ -0,0 +1,164 @@ +session->userdata('user_date_format')) { + // If Logged in and session exists + $custom_date_format = $this->session->userdata('user_date_format'); +} else { + // Get Default date format from /config/wavelog.php + $custom_date_format = $this->config->item('qso_date_format'); +} +?> + +
+
+
+
+
+
+
+

+

s

+

+
+
+
+
+
+
+
+
+
+

+

s

+

+
+
+
+
+ +
+
+
+
+ -
+ -
+ - +
+
+
+ + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
#
' . htmlspecialchars($qso['callsign']) . ''; ?>
+
+
+ + + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
#
' . htmlspecialchars($qso['callsign']) . ''; ?>
+
+
+ + + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
#
' . htmlspecialchars($qso['callsign']) . ''; ?>
+
+
+ + + +
+ +
+ \ No newline at end of file diff --git a/application/views/calltester/index.php b/application/views/calltester/index.php index 043e76862..9e7e32c1a 100644 --- a/application/views/calltester/index.php +++ b/application/views/calltester/index.php @@ -13,7 +13,11 @@ +
+ + +
- \ No newline at end of file + diff --git a/assets/js/sections/calltester.js b/assets/js/sections/calltester.js index dfc50283e..4ff9760ea 100644 --- a/assets/js/sections/calltester.js +++ b/assets/js/sections/calltester.js @@ -1,10 +1,13 @@ $('#startDxccCheck').on('click', function() { let de = $('#de').val(); + let compare = $('#compareDxccClass').prop('checked'); $('.result').html('
Loading...
'); $.ajax({ url: site_url + '/calltester/doDxccCheck', type: "POST", - data: {de: de}, + data: {de: de, + compare: compare + }, success: function(response) { $('.result').html(response); }, @@ -12,4 +15,4 @@ $('.result').html(''); } }); - }); \ No newline at end of file + }); diff --git a/src/Dxcc/Dxcc.php b/src/Dxcc/Dxcc.php index b52bb58ff..8b0c616b8 100644 --- a/src/Dxcc/Dxcc.php +++ b/src/Dxcc/Dxcc.php @@ -101,11 +101,11 @@ class Dxcc { if ($startDate == null && $endDate == null) return $dxccEntry; - if ($date < $endDate && $date >= $startDate) + if ($date <= $endDate && $date >= $startDate) return $dxccEntry; if ($endDate == null && $date >= $startDate) return $dxccEntry; - if ($date < $endDate && $startDate == null) + if ($date <= $endDate && $startDate == null) return $dxccEntry; } } @@ -258,6 +258,7 @@ class Dxcc { if ($date == null) { $dxcc_exceptions = $CI->db->select('entity, adif, cqz, start, end, call, cont, long, lat') + ->order_by('start desc, end desc') ->get('dxcc_exceptions'); } else { $dxcc_exceptions = $CI->db->select('entity, adif, cqz, start, end, call, cont, long, lat') @@ -269,6 +270,7 @@ class Dxcc { ->where('end >=', $date) ->or_where('end IS NULL') ->group_end() + ->order_by('start desc, end desc') ->get('dxcc_exceptions'); } @@ -289,6 +291,7 @@ class Dxcc { if ($date == null) { $dxcc_result = $CI->db->select('*') + ->order_by('start desc, end desc') ->get('dxcc_prefixes'); } else { $dxcc_result = $CI->db->select('*') @@ -300,6 +303,7 @@ class Dxcc { ->where('end >=', $date) ->or_where('end IS NULL') ->group_end() + ->order_by('start desc, end desc') ->get('dxcc_prefixes'); }