diff --git a/application/controllers/Update.php b/application/controllers/Update.php index 24b80c296..a26c7a4a7 100644 --- a/application/controllers/Update.php +++ b/application/controllers/Update.php @@ -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)) { diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 809f1971b..74c640d7b 100644 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -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"); diff --git a/application/models/Logbookadvanced_model.php b/application/models/Logbookadvanced_model.php index f069bce58..27a3ac783 100644 --- a/application/models/Logbookadvanced_model.php +++ b/application/models/Logbookadvanced_model.php @@ -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"); + } } diff --git a/application/views/update/index.php b/application/views/update/index.php index 76befdc69..06751ad19 100644 --- a/application/views/update/index.php +++ b/application/views/update/index.php @@ -24,39 +24,6 @@
- -
- = __("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."); ?>
-
= __("WARNING"); ?>: = __("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!"); ?>
-