Add update function for empty distances
这个提交包含在:
		
							父节点
							
								
									dc218854b8
								
							
						
					
					
						当前提交
						42882a0ef4
					
				
					共有  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,44 +3,60 @@ | ||||||
| 
 | 
 | ||||||
| 	<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"> | ||||||
| 		 </div> | 				<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"> | 		<div class="card-body"> | ||||||
| 			<p class="card-text">Here you can update the DXCC lookup data that is used for displaying callsign information.</p> | 			<div class="tab-content" id="myTabContent"> | ||||||
| 			<p class="card-text">This data is provided by <a href="https://clublog.org/">Clublog</a>.</p> | 				<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')) { ?>
 | 					<?php if(!extension_loaded('xml')) { ?>
 | ||||||
| 				<div class="alert alert-danger" role="alert"> | 						<div class="alert alert-danger" role="alert"> | ||||||
| 				You must install php-xml for this to work. | 						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> | 				</div> | ||||||
| 			<?php } else { ?>
 | 				<div class="tab-pane fade" id="distance" role="tabpanel" aria-labelledby="distance-tab"> | ||||||
| 				<h5>Check for DXCC Data Updates</h5> | 					<p class="card-text">Here you can update QSOs with missing distance information.</p> | ||||||
| 				<input type="submit" class="btn btn-primary" id="btn_update_dxcc" value="Update DXCC Data" /> | 					<p><a class="btn btn-primary" href="<?php echo site_url('update/update_distances');?>">Update distance data</a></p> | ||||||
| 
 | 				</div> | ||||||
| 				<div id="dxcc_update_status">Status:</br></div> | 			</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> | 		</div> | ||||||
| 	</div> | 	</div> | ||||||
| </div> | </div> | ||||||
|  |  | ||||||
		正在加载…
	
		在新工单中引用