Add update function for empty distances

这个提交包含在:
phl0 2023-06-19 14:02:08 +02:00
父节点 dc218854b8
当前提交 42882a0ef4
找不到此签名对应的密钥
GPG 密钥 ID: 48EA1E640798CA9A
共有 3 个文件被更改,包括 87 次插入36 次删除

查看文件

@ -251,6 +251,11 @@ class Update extends CI_Controller {
$this->logbook_model->check_missing_continent(); $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){ public function check_missing_grid($all = false){
$this->load->model('logbook_model'); $this->load->model('logbook_model');
$this->logbook_model->check_missing_grid_id($all); $this->logbook_model->check_missing_grid_id($all);

查看文件

@ -3618,6 +3618,36 @@ class Logbook_model extends CI_Model {
print("$count updated\n"); 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() { public function check_for_station_id() {
$this->db->where('station_id =', NULL); $this->db->where('station_id =', NULL);
$query = $this->db->get($this->config->item('table_name')); $query = $this->db->get($this->config->item('table_name'));

查看文件

@ -3,9 +3,19 @@
<div class="card"> <div class="card">
<div class="card-header"> <div class="card-header">
DXCC Lookup Data <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>
<div class="card-body"> <div class="card-body">
<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">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> <p class="card-text">This data is provided by <a href="https://clublog.org/">Clublog</a>.</p>
@ -42,6 +52,12 @@
</style> </style>
<?php } ?> <?php } ?>
</div> </div>
<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>
</div> </div>