mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 02:14:13 +00:00
Moved DXCC QSO updater from update to lba
This commit is contained in:
@@ -327,17 +327,6 @@ class Update extends CI_Controller {
|
||||
}
|
||||
}
|
||||
|
||||
public function check_missing_dxcc($all = false){
|
||||
$this->load->model('user_model');
|
||||
if (!$this->user_model->authorize(99)) {
|
||||
$this->session->set_flashdata('error', __("You're not allowed to do that!"));
|
||||
redirect('dashboard');
|
||||
}
|
||||
|
||||
$this->load->model('logbook_model');
|
||||
$this->logbook_model->check_missing_dxcc_id($all);
|
||||
}
|
||||
|
||||
public function check_missing_grid($all = false){
|
||||
$this->load->model('user_model');
|
||||
if (!$this->user_model->authorize(99)) {
|
||||
|
||||
@@ -5991,36 +5991,6 @@ class Logbook_model extends CI_Model {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
public function check_missing_dxcc_id($all) {
|
||||
ini_set('memory_limit', '-1'); // This consumes a much of Memory!
|
||||
$this->db->trans_start(); // Transaction has to be started here, because otherwise we're trying to update rows which are locked by the select
|
||||
$this->db->select("COL_PRIMARY_KEY, COL_CALL, COL_TIME_ON, COL_TIME_OFF"); // get all records with no COL_DXCC
|
||||
|
||||
if (!$all) { // check which to update - records with no dxcc or all records
|
||||
$this->db->where("COL_DXCC is NULL");
|
||||
}
|
||||
|
||||
$r = $this->db->get($this->config->item('table_name'));
|
||||
|
||||
$count = 0;
|
||||
if ($r->num_rows() > 0) { //query dxcc_prefixes
|
||||
$sql = "update " . $this->config->item('table_name') . " set COL_COUNTRY = ?, COL_DXCC=? where COL_PRIMARY_KEY=?";
|
||||
$q = $this->db->conn_id->prepare($sql); // PREPARE this statement. For DB this means: No parsing overhead, parse once use many (see execute query below)
|
||||
foreach ($r->result_array() as $row) {
|
||||
$qso_date = $row['COL_TIME_OFF'] == '' ? $row['COL_TIME_ON'] : $row['COL_TIME_OFF'];
|
||||
$qso_date = date("Y-m-d", strtotime($qso_date));
|
||||
$d = $this->check_dxcc_table($row['COL_CALL'], $qso_date);
|
||||
if ($d[0] != 'Not Found') {
|
||||
$q->execute(array(addslashes(ucwords(strtolower($d[1]), "- (/")), $d[0], $row['COL_PRIMARY_KEY']));
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->db->trans_complete();
|
||||
print("$count updated\n");
|
||||
}
|
||||
|
||||
public function check_missing_grid_id($all) {
|
||||
// get all records with no COL_GRIDSQUARE
|
||||
$this->db->select("COL_PRIMARY_KEY, COL_CALL, COL_TIME_ON, COL_TIME_OFF");
|
||||
|
||||
@@ -1592,4 +1592,39 @@ class Logbookadvanced_model extends CI_Model {
|
||||
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
/*
|
||||
This was moved from update to the advanced logbook. Maninly because it affected all QSOs in the logbook, with not filters on users or stations.
|
||||
We need to ensure that we only update the relevant QSOs, filtered on user.
|
||||
The function needs a rewrite to add filtering on user/station.
|
||||
*/
|
||||
public function check_missing_dxcc_id($all) {
|
||||
ini_set('memory_limit', '-1'); // This consumes a lot of Memory!
|
||||
$this->db->trans_start(); // Transaction has to be started here, because otherwise we're trying to update rows which are locked by the select
|
||||
$this->db->select("COL_PRIMARY_KEY, COL_CALL, COL_TIME_ON, COL_TIME_OFF"); // get all records with no COL_DXCC
|
||||
|
||||
if (!$all) { // check which to update - records with no dxcc or all records
|
||||
$this->db->where("COL_DXCC is NULL");
|
||||
}
|
||||
|
||||
$r = $this->db->get($this->config->item('table_name'));
|
||||
$this->load->model('logbook_model');
|
||||
|
||||
$count = 0;
|
||||
if ($r->num_rows() > 0) { //query dxcc_prefixes
|
||||
$sql = "update " . $this->config->item('table_name') . " set COL_COUNTRY = ?, COL_DXCC=? where COL_PRIMARY_KEY=?";
|
||||
$q = $this->db->conn_id->prepare($sql); // PREPARE this statement. For DB this means: No parsing overhead, parse once use many (see execute query below)
|
||||
foreach ($r->result_array() as $row) {
|
||||
$qso_date = $row['COL_TIME_OFF'] == '' ? $row['COL_TIME_ON'] : $row['COL_TIME_OFF'];
|
||||
$qso_date = date("Y-m-d", strtotime($qso_date));
|
||||
$d = $this->logbook_model->check_dxcc_table($row['COL_CALL'], $qso_date);
|
||||
if ($d[0] != 'Not Found') {
|
||||
$q->execute(array(addslashes(ucwords(strtolower($d[1]), "- (/")), $d[0], $row['COL_PRIMARY_KEY']));
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->db->trans_complete();
|
||||
print("$count updated\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,39 +24,6 @@
|
||||
<button type="submit" class="btn btn-primary ld-ext-right" id="btn_update_dxcc"><div class="ld ld-ring ld-spin"></div><?= __("Update DXCC Data"); ?></button>
|
||||
|
||||
<div id="dxcc_update_status" class="alert alert-secondary mt-3 w-25 w-lg-100" style="display: none;"><?= __("Status:"); ?></br></div>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
<h5><?= __("Apply DXCC Data to Logbook"); ?></h5>
|
||||
<p class="card-text">
|
||||
<?= __("After updating, Wavelog can fill in missing callsign information in the logbook using the newly-obtained DXCC data.
|
||||
You can choose to check just the QSOs in the logbook that are missing DXCC metadata or to re-check the entire logbook
|
||||
and update existing metadata as well, in case it has changed."); ?>
|
||||
<br/><br/><b class="badge text-bg-danger"><?= __("WARNING"); ?></b>: <?= __("This affects ALL QSOs of ANY user on this instance. The function is deprectated and will be removed in a future version of Wavelog. As replacement use the Logbook-Advanced!"); ?>
|
||||
</p>
|
||||
<button class="btn btn-primary mb-3 ld-ext-right"
|
||||
hx-get="<?php echo site_url('update/check_missing_dxcc');?>"
|
||||
hx-target="#missing_dxcc_results"
|
||||
hx-on:htmx:before-request="this.disabled = true; this.classList.add('running');"
|
||||
hx-on:htmx:after-request="this.disabled = false; this.classList.remove('running'); document.getElementById('missing_dxcc_results').style.display = 'block';">
|
||||
<?= __("Check QSOs missing DXCC data"); ?>
|
||||
<div class="ld ld-ring ld-spin"></div>
|
||||
</button><br>
|
||||
<div id="missing_dxcc_results" class="alert alert-secondary mb-3 w-25 w-lg-100" style="display: none;"></div>
|
||||
<button class="btn btn-primary mb-3 ld-ext-right"
|
||||
hx-get="<?php echo site_url('update/check_missing_dxcc/all');?>"
|
||||
hx-target="#missing_dxcc_results_all"
|
||||
hx-on:htmx:before-request="this.disabled = true; this.classList.add('running');"
|
||||
hx-on:htmx:after-request="this.disabled = false; this.classList.remove('running'); document.getElementById('missing_dxcc_results_all').style.display = 'block';">
|
||||
<?= __("Re-check all QSOs in logbook"); ?>
|
||||
<div class="ld ld-ring ld-spin"></div>
|
||||
</button>
|
||||
<div id="missing_dxcc_results_all" class="alert alert-secondary mb-3 w-25 w-lg-100" style="display: none;"></div>
|
||||
<style>
|
||||
#dxcc_update_status{
|
||||
display: None;
|
||||
}
|
||||
</style>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user