From 00b0666ff4d36532c7fe5c54c4f4739152c5a6cb Mon Sep 17 00:00:00 2001 From: phl0 Date: Sat, 17 Aug 2024 22:39:33 +0200 Subject: [PATCH] Add option to update distance information for all QSOs --- application/controllers/Update.php | 4 ++-- application/models/Logbook_model.php | 9 ++++++--- application/views/update/index.php | 2 ++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/application/controllers/Update.php b/application/controllers/Update.php index 20aa07ce9..3cd5d4180 100644 --- a/application/controllers/Update.php +++ b/application/controllers/Update.php @@ -289,7 +289,7 @@ class Update extends CI_Controller { $this->logbook_model->check_missing_continent(); } - public function update_distances() { + public function update_distances($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!")); @@ -297,7 +297,7 @@ class Update extends CI_Controller { } $this->load->model('logbook_model'); - $this->logbook_model->update_distances(); + $this->logbook_model->update_distances($all); } public function check_missing_grid($all = false){ diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 3d2f160d0..f17c8c482 100644 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -4670,14 +4670,17 @@ function lotw_last_qsl_date($user_id) { print("$count updated\n"); } - public function update_distances(){ + public function update_distances($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_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) or (COL_DISTANCE = 0))"); + if (!$all) { + $this->db->where("((COL_DISTANCE is NULL) or (COL_DISTANCE = 0))"); + } $this->db->where("COL_GRIDSQUARE is NOT NULL"); $this->db->where("COL_GRIDSQUARE != ''"); $this->db->where("COL_GRIDSQUARE != station_gridsquare"); - $this->db->trans_start(); $query = $this->db->get($this->config->item('table_name')); $count = 0; diff --git a/application/views/update/index.php b/application/views/update/index.php index c74330129..e7f224e6b 100644 --- a/application/views/update/index.php +++ b/application/views/update/index.php @@ -58,6 +58,8 @@

+

+