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'); +} +?> + +
= __("Calls tested:"); ?> = $class_calls_tested; ?>
+= __("Execution time:"); ?> = round($class_execution_time, 2); ?>s
+= __("Issues found:"); ?> = $class_total_issues; ?>
+= __("Calls tested:"); ?> = $model_calls_tested; ?>
+= __("Execution time:"); ?> = round($model_execution_time, 2); ?>s
+= __("Issues found:"); ?> = $model_total_issues; ?>
+| # | += __("Callsign"); ?> | += __("QSO Date"); ?> | += __("Station Profile"); ?> | += __("Existing DXCC"); ?> | += __("Existing ADIF"); ?> | += __("Result DXCC"); ?> | += __("Result ADIF"); ?> | +
|---|---|---|---|---|---|---|---|
| + | ' . htmlspecialchars($qso['callsign']) . ''; ?> | ++ | + | + | + | + | + |
| # | += __("Callsign"); ?> | += __("QSO Date"); ?> | += __("Station Profile"); ?> | += __("Existing DXCC"); ?> | += __("Existing ADIF"); ?> | += __("Result DXCC"); ?> | += __("Result ADIF"); ?> | +
|---|---|---|---|---|---|---|---|
| + | ' . htmlspecialchars($qso['callsign']) . ''; ?> | ++ | + | + | + | + | + |
| # | += __("Callsign"); ?> | += __("QSO Date"); ?> | += __("Station Profile"); ?> | += __("Existing DXCC"); ?> | += __("Existing ADIF"); ?> | += __("Result DXCC"); ?> | += __("Result ADIF"); ?> | +
|---|---|---|---|---|---|---|---|
| + | ' . htmlspecialchars($qso['callsign']) . ''; ?> | ++ | + | + | + | + | + |