Skip to content
Merged

2.8.0 #3380

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion application/config/migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
|
*/

$config['migration_version'] = 233;
$config['migration_version'] = 235;

/*
|--------------------------------------------------------------------------
Expand Down
13 changes: 8 additions & 5 deletions application/controllers/Dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,14 @@ function upcoming_dxcc_component()

$data['thisWeekRecords'] = $thisWeekRecords;

usort($data['thisWeekRecords'], function ($a, $b) {
$dateA = new DateTime($a['1']);
$dateB = new DateTime($b['1']);
return $dateA <=> $dateB;
});
// Only sort if we have valid records (not an error)
if (!isset($thisWeekRecords['error']) && !empty($thisWeekRecords)) {
usort($data['thisWeekRecords'], function ($a, $b) {
$dateA = new DateTime($a['1']);
$dateB = new DateTime($b['1']);
return $dateA <=> $dateB;
});
}

$this->load->view('components/upcoming_dxccs', $data);
}
Expand Down
95 changes: 95 additions & 0 deletions application/controllers/Dxcluster.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ function __construct()
function index()
{
$data['page_title'] = "DX Cluster Spots";

// Load radio data for CAT control
$this->load->model('cat');
$data['radios'] = $this->cat->radios();

/// Load layout

Expand Down Expand Up @@ -124,4 +128,95 @@ public function qsy() {
echo json_encode(['success' => false, 'message' => 'Failed to queue QSY command']);
}
}

/*
* Check if callsigns have been worked
* POST /dxcluster/check_worked
*/
public function check_worked() {
header('Content-Type: application/json');

$this->load->model('logbook_model');
$this->load->model('logbooks_model');

// Get JSON input
$input = json_decode(file_get_contents("php://input"), true);

if (!isset($input['callsigns']) || !is_array($input['callsigns'])) {
http_response_code(400);
echo json_encode(['success' => false, 'message' => 'Missing or invalid callsigns array']);
return;
}

// Limit batch size to prevent excessive load
$max_batch_size = 50;
if (count($input['callsigns']) > $max_batch_size) {
$input['callsigns'] = array_slice($input['callsigns'], 0, $max_batch_size);
}

// Get logbook locations for the active logbook
$logbook_id = $this->session->userdata('active_station_logbook');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($logbook_id);

if (!$logbooks_locations_array) {
http_response_code(500);
echo json_encode(['success' => false, 'message' => 'No logbook locations found']);
return;
}

$results = [];

foreach ($input['callsigns'] as $item) {
$callsign = $item['callsign'];
$band = isset($item['band']) ? $item['band'] : null;

// Get DXCC entity for this callsign
$dxcc_info = $this->logbook_model->dxcc_lookup($callsign, date('Ymd'));
$dxcc = isset($dxcc_info['adif']) ? $dxcc_info['adif'] : null;

// Check if worked on this band
$worked_on_band = false;
if ($band) {
$worked_on_band = $this->logbook_model->check_if_callsign_worked_in_logbook($callsign, $logbooks_locations_array, $band) > 0;
}

// Check if worked on any band
$worked_overall = $this->logbook_model->check_if_callsign_worked_in_logbook($callsign, $logbooks_locations_array, null) > 0;

// Check if DXCC entity is worked on this band
$dxcc_worked_on_band = false;
if ($dxcc && $band) {
$this->db->select('COL_DXCC');
$this->db->where_in('station_id', $logbooks_locations_array);
$this->db->where('COL_DXCC', $dxcc);
$this->db->where('COL_BAND', $band);
$this->db->limit(1);
$query = $this->db->get($this->config->item('table_name'));
$dxcc_worked_on_band = $query->num_rows() > 0;
}

// Check if DXCC entity is worked on any band
$dxcc_worked_overall = false;
if ($dxcc) {
$this->db->select('COL_DXCC');
$this->db->where_in('station_id', $logbooks_locations_array);
$this->db->where('COL_DXCC', $dxcc);
$this->db->limit(1);
$query = $this->db->get($this->config->item('table_name'));
$dxcc_worked_overall = $query->num_rows() > 0;
}

$results[$callsign] = [
'worked_on_band' => $worked_on_band,
'worked_overall' => $worked_overall,
'band' => $band,
'dxcc' => $dxcc,
'dxcc_worked_on_band' => $dxcc_worked_on_band,
'dxcc_worked_overall' => $dxcc_worked_overall,
'country' => isset($dxcc_info['entity']) ? $dxcc_info['entity'] : null
];
}

echo json_encode(['success' => true, 'results' => $results]);
}
}
Loading