Add update function for empty distances

pull/2215/head
phl0 2023-06-19 14:02:08 +02:00
rodzic dc218854b8
commit 42882a0ef4
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 48EA1E640798CA9A
3 zmienionych plików z 87 dodań i 36 usunięć

Wyświetl plik

@ -251,6 +251,11 @@ class Update extends CI_Controller {
$this->logbook_model->check_missing_continent();
}
public function update_distances() {
$this->load->model('logbook_model');
$this->logbook_model->update_distances();
}
public function check_missing_grid($all = false){
$this->load->model('logbook_model');
$this->logbook_model->check_missing_grid_id($all);

Wyświetl plik

@ -3618,6 +3618,36 @@ class Logbook_model extends CI_Model {
print("$count updated\n");
}
public function update_distances(){
$this->db->select("COL_PRIMARY_KEY, COL_GRIDSQUARE, station_gridsquare");
$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
$this->db->where("COL_DISTANCE is NULL");
$this->db->where("COL_GRIDSQUARE is NOT NULL");
$this->db->where("COL_GRIDSQUARE != ''");
$this->db->trans_start();
$query = $this->db->get($this->config->item('table_name'));
$count = 0;
if ($query->num_rows() > 0){
print("Affected QSOs: ".$this->db->affected_rows()." <br />");
$this->load->library('Qra');
foreach ($query->result() as $row) {
$distance = $this->qra->distance($row->station_gridsquare, $row->COL_GRIDSQUARE, 'K');
$data = array(
'COL_DISTANCE' => $distance,
);
$this->db->where(array('COL_PRIMARY_KEY' => $row->COL_PRIMARY_KEY));
$this->db->update($this->config->item('table_name'), $data);
$count++;
}
print("QSOs updated: ".$count);
} else {
print "No QSOs affected.";
}
$this->db->trans_complete();
}
public function check_for_station_id() {
$this->db->where('station_id =', NULL);
$query = $this->db->get($this->config->item('table_name'));

Wyświetl plik

@ -3,44 +3,60 @@
<div class="card">
<div class="card-header">
DXCC Lookup Data
</div>
<ul style="font-size: 15px;" class="nav nav-tabs card-header-tabs pull-right" id="myTab" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="dxcc-tab" data-toggle="tab" href="#dxcc" role="tab" aria-controls="update" aria-selected="true">DXCC Lookup Data</a>
</li>
<li class="nav-item">
<a class="nav-link" id="distance-tab" data-toggle="tab" href="#distance" role="tab" aria-controls="update" aria-selected="false">Distance Data</a>
</li>
</ul>
</div>
<div class="card-body">
<p class="card-text">Here you can update the DXCC lookup data that is used for displaying callsign information.</p>
<p class="card-text">This data is provided by <a href="https://clublog.org/">Clublog</a>.</p>
<?php if(!extension_loaded('xml')) { ?>
<div class="alert alert-danger" role="alert">
You must install php-xml for this to work.
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="dxcc" role="tabpanel" aria-labelledby="dxcc-tab">
<p class="card-text">Here you can update the DXCC lookup data that is used for displaying callsign information.</p>
<p class="card-text">This data is provided by <a href="https://clublog.org/">Clublog</a>.</p>
<?php if(!extension_loaded('xml')) { ?>
<div class="alert alert-danger" role="alert">
You must install php-xml for this to work.
</div>
<?php } else { ?>
<h5>Check for DXCC Data Updates</h5>
<input type="submit" class="btn btn-primary" id="btn_update_dxcc" value="Update DXCC Data" />
<div id="dxcc_update_status">Status:</br></div>
<br/>
<br/>
<h5>Apply DXCC Data to Logbook</h5>
<p class="card-text">
After updating, Cloudlog 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.
</p>
<p><a class="btn btn-primary" href="<?php echo site_url('update/check_missing_dxcc');?>">Check QSOs missing DXCC data</a></p>
<p><a class="btn btn-primary" href="<?php echo site_url('update/check_missing_dxcc/all');?>">Re-check all QSOs in logbook</a></p>
<h5>Apply Continent Data to Logbook</h5>
<p class="card-text">
This function can be used to update QSO continent information for all QSOs in Cloudlog missing that information.
</p>
<p><a class="btn btn-primary" href="<?php echo site_url('update/check_missing_continent');?>">Check QSOs missing continent data</a></p>
<style>
#dxcc_update_status{
display: None;
}
</style>
<?php } ?>
</div>
<?php } else { ?>
<h5>Check for DXCC Data Updates</h5>
<input type="submit" class="btn btn-primary" id="btn_update_dxcc" value="Update DXCC Data" />
<div id="dxcc_update_status">Status:</br></div>
<br/>
<br/>
<h5>Apply DXCC Data to Logbook</h5>
<p class="card-text">
After updating, Cloudlog 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.
</p>
<p><a class="btn btn-primary" href="<?php echo site_url('update/check_missing_dxcc');?>">Check QSOs missing DXCC data</a></p>
<p><a class="btn btn-primary" href="<?php echo site_url('update/check_missing_dxcc/all');?>">Re-check all QSOs in logbook</a></p>
<h5>Apply Continent Data to Logbook</h5>
<p class="card-text">
This function can be used to update QSO continent information for all QSOs in Cloudlog missing that information.
</p>
<p><a class="btn btn-primary" href="<?php echo site_url('update/check_missing_continent');?>">Check QSOs missing continent data</a></p>
<style>
#dxcc_update_status{
display: None;
}
</style>
<?php } ?>
<div class="tab-pane fade" id="distance" role="tabpanel" aria-labelledby="distance-tab">
<p class="card-text">Here you can update QSOs with missing distance information.</p>
<p><a class="btn btn-primary" href="<?php echo site_url('update/update_distances');?>">Update distance data</a></p>
</div>
</div>
</div>
</div>
</div>