mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 02:14:13 +00:00
Updated for method comparison and dxcc fixes
This commit is contained in:
@@ -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') . '
|
||||
|
||||
164
application/views/calltester/comparison_result.php
Normal file
164
application/views/calltester/comparison_result.php
Normal file
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
$i = 0;
|
||||
|
||||
// Get Date format
|
||||
if($this->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');
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="row mb-4">
|
||||
<div class="col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h6 class="card-title mb-0"><?= __("DXCC Class Results"); ?></h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p><strong><?= __("Calls tested:"); ?></strong> <?= $class_calls_tested; ?></p>
|
||||
<p><strong><?= __("Execution time:"); ?></strong> <?= round($class_execution_time, 2); ?>s</p>
|
||||
<p><strong><?= __("Issues found:"); ?></strong> <?= $class_total_issues; ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h6 class="card-title mb-0"><?= __("Logbook Model Results"); ?></h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p><strong><?= __("Calls tested:"); ?></strong> <?= $model_calls_tested; ?></p>
|
||||
<p><strong><?= __("Execution time:"); ?></strong> <?= round($model_execution_time, 2); ?>s</p>
|
||||
<p><strong><?= __("Issues found:"); ?></strong> <?= $model_total_issues; ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-4">
|
||||
<div class="col-12">
|
||||
<div class="alert alert-info">
|
||||
<strong><?= __("Comparison Summary"); ?></strong><br>
|
||||
- <?= __("Only found in DXCC Class:"); ?> <?= count($only_in_class); ?><br>
|
||||
- <?= __("Only found in Logbook Model:"); ?> <?= count($only_in_model); ?><br>
|
||||
- <?= __("Found in both methods:"); ?> <?= count($common_issues); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($only_in_class): ?>
|
||||
<div class="mb-4">
|
||||
<h6 class="text-danger"><?= __("Issues found only in DXCC Class (not in Logbook Model):"); ?> <?= count($only_in_class); ?></h6>
|
||||
<div class="table-responsive" style="max-height:50vh; overflow:auto;">
|
||||
<table class="table table-sm table-striped table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th><?= __("Callsign"); ?></th>
|
||||
<th><?= __("QSO Date"); ?></th>
|
||||
<th><?= __("Station Profile"); ?></th>
|
||||
<th><?= __("Existing DXCC"); ?></th>
|
||||
<th><?= __("Existing ADIF"); ?></th>
|
||||
<th><?= __("Result DXCC"); ?></th>
|
||||
<th><?= __("Result ADIF"); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($only_in_class as $qso): ?>
|
||||
<tr>
|
||||
<td><?php echo ++$i; ?></td>
|
||||
<td><?php echo '<a id="edit_qso" href="javascript:displayQso(' . $qso['id'] . ')">' . htmlspecialchars($qso['callsign']) . '</a>'; ?></td>
|
||||
<td><?php echo date($custom_date_format, strtotime($qso['qso_date'])); ?></td>
|
||||
<td><?php echo $qso['station_profile']; ?></td>
|
||||
<td><?php echo htmlspecialchars(ucwords(strtolower($qso['existing_dxcc']), "- (/"), ENT_QUOTES, 'UTF-8'); ?></td>
|
||||
<td><?php echo $qso['existing_adif']; ?></td>
|
||||
<td><?php echo htmlspecialchars(ucwords(strtolower($qso['result_country']), "- (/"), ENT_QUOTES, 'UTF-8'); ?></td>
|
||||
<td><?php echo $qso['result_adif']; ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($only_in_model): ?>
|
||||
<div class="mb-4">
|
||||
<h6 class="text-warning"><?= __("Issues found only in Logbook Model (not in DXCC Class):"); ?> <?= count($only_in_model); ?></h6>
|
||||
<div class="table-responsive" style="max-height:50vh; overflow:auto;">
|
||||
<table class="table table-sm table-striped table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th><?= __("Callsign"); ?></th>
|
||||
<th><?= __("QSO Date"); ?></th>
|
||||
<th><?= __("Station Profile"); ?></th>
|
||||
<th><?= __("Existing DXCC"); ?></th>
|
||||
<th><?= __("Existing ADIF"); ?></th>
|
||||
<th><?= __("Result DXCC"); ?></th>
|
||||
<th><?= __("Result ADIF"); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php $i = 0; foreach ($only_in_model as $qso): ?>
|
||||
<tr>
|
||||
<td><?php echo ++$i; ?></td>
|
||||
<td><?php echo '<a id="edit_qso" href="javascript:displayQso(' . $qso['id'] . ')">' . htmlspecialchars($qso['callsign']) . '</a>'; ?></td>
|
||||
<td><?php echo date($custom_date_format, strtotime($qso['qso_date'])); ?></td>
|
||||
<td><?php echo $qso['station_profile']; ?></td>
|
||||
<td><?php echo htmlspecialchars(ucwords(strtolower($qso['existing_dxcc']), "- (/"), ENT_QUOTES, 'UTF-8'); ?></td>
|
||||
<td><?php echo $qso['existing_adif']; ?></td>
|
||||
<td><?php echo htmlspecialchars(ucwords(strtolower($qso['result_country']), "- (/"), ENT_QUOTES, 'UTF-8'); ?></td>
|
||||
<td><?php echo $qso['result_adif']; ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($common_issues): ?>
|
||||
<div class="mb-4">
|
||||
<h6 class="text-success"><?= __("Issues found in both methods:"); ?> <?= count($common_issues); ?></h6>
|
||||
<div class="table-responsive" style="max-height:50vh; overflow:auto;">
|
||||
<table class="table table-sm table-striped table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th><?= __("Callsign"); ?></th>
|
||||
<th><?= __("QSO Date"); ?></th>
|
||||
<th><?= __("Station Profile"); ?></th>
|
||||
<th><?= __("Existing DXCC"); ?></th>
|
||||
<th><?= __("Existing ADIF"); ?></th>
|
||||
<th><?= __("Result DXCC"); ?></th>
|
||||
<th><?= __("Result ADIF"); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php $i = 0; foreach ($common_issues as $qso): ?>
|
||||
<tr>
|
||||
<td><?php echo ++$i; ?></td>
|
||||
<td><?php echo '<a id="edit_qso" href="javascript:displayQso(' . $qso['id'] . ')">' . htmlspecialchars($qso['callsign']) . '</a>'; ?></td>
|
||||
<td><?php echo date($custom_date_format, strtotime($qso['qso_date'])); ?></td>
|
||||
<td><?php echo $qso['station_profile']; ?></td>
|
||||
<td><?php echo htmlspecialchars(ucwords(strtolower($qso['existing_dxcc']), "- (/"), ENT_QUOTES, 'UTF-8'); ?></td>
|
||||
<td><?php echo $qso['existing_adif']; ?></td>
|
||||
<td><?php echo htmlspecialchars(ucwords(strtolower($qso['result_country']), "- (/"), ENT_QUOTES, 'UTF-8'); ?></td>
|
||||
<td><?php echo $qso['result_adif']; ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!$only_in_class && !$only_in_model && !$common_issues): ?>
|
||||
<div class="alert alert-success">
|
||||
<?= __("No DXCC issues found in either method. All calls have correct DXCC information."); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
@@ -13,7 +13,11 @@
|
||||
<?php } ?>
|
||||
</select>
|
||||
<button id="startDxccCheck" class="btn btn-primary btn-sm"><?= __("Start DXCC Check"); ?></button>
|
||||
<div class="form-check me-2 mx-2">
|
||||
<input type="checkbox" class="form-check-input" id="compareDxccClass" name="compareDxccClass">
|
||||
<label class="form-check-label" for="compareDxccClass"><?= __("Compare DXCC class and logbook model"); ?></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class='result'>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
$('#startDxccCheck').on('click', function() {
|
||||
let de = $('#de').val();
|
||||
let compare = $('#compareDxccClass').prop('checked');
|
||||
$('.result').html('<div class="spinner-border text-primary" role="status"><span class="visually-hidden">Loading...</span></div> <?= __("Processing...") ?>');
|
||||
$.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('<div class="alert alert-danger" role="alert"><?= __("An error occurred while processing the request.") ?></div>');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user