mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
@@ -22,7 +22,7 @@ $config['migration_enabled'] = TRUE;
|
||||
|
|
||||
*/
|
||||
|
||||
$config['migration_version'] = 172;
|
||||
$config['migration_version'] = 173;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
||||
61
application/migrations/173_main_index_cleanup.php
Normal file
61
application/migrations/173_main_index_cleanup.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Migration_main_index_cleanup extends CI_Migration {
|
||||
|
||||
public function up() {
|
||||
$this->rm_ix('HRD_IDX_COL_CQZ');
|
||||
$this->rm_ix('gridsquares');
|
||||
$this->rm_ix('station_id');
|
||||
$this->rm_ix('HRD_IDX_COL_BAND');
|
||||
$this->rm_ix('HRD_IDX_COL_CALL');
|
||||
$this->rm_ix('HRD_IDX_COL_CONT');
|
||||
$this->rm_ix('HRD_IDX_COL_DXCC');
|
||||
$this->rm_ix('HRD_IDX_COL_IOTA');
|
||||
$this->rm_ix('HRD_IDX_COL_MODE');
|
||||
$this->rm_ix('HRD_IDX_COL_PFX');
|
||||
$this->rm_ix('HRD_IDX_COL_TIME_ON');
|
||||
$this->add_ix('idx_HRD_DBL_CHK','`station_id`, `COL_CALL`,`COL_BAND`,`COL_MODE`');
|
||||
$this->add_ix('idx_HRD_COL_BAND_station_id','`station_id`,`COL_BAND`,`COL_TIME_ON` desc');
|
||||
$this->add_ix('idx_HRD_COL_CALL_station_id','`station_id`,`COL_CALL`,`COL_TIME_ON` desc');
|
||||
$this->add_ix('idx_HRD_COL_DXCC_station_id','`station_id`,`COL_DXCC`,`COL_TIME_ON` desc');
|
||||
$this->add_ix('idx_HRD_station_id','`station_id`,`COL_TIME_ON` desc');
|
||||
}
|
||||
|
||||
|
||||
public function down(){
|
||||
$this->rm_ix('idx_HRD_DBL_CHK');
|
||||
$this->rm_ix('idx_HRD_COL_BAND_station_id');
|
||||
$this->rm_ix('idx_HRD_COL_CALL_station_id');
|
||||
$this->rm_ix('idx_HRD_COL_DXCC_station_id');
|
||||
$this->rm_ix('idx_HRD_station_id');
|
||||
$this->add_ix('HRD_IDX_COL_CQZ','`COL_CQZ`');
|
||||
$this->add_ix('gridsquares','`COL_GRIDSQUARE`');
|
||||
$this->add_ix('station_id','`station_id`');
|
||||
$this->add_ix('HRD_IDX_COL_BAND','`COL_BAND`');
|
||||
$this->add_ix('HRD_IDX_COL_CALL','`COL_CALL`');
|
||||
$this->add_ix('HRD_IDX_COL_CONT','`COL_CONT`');
|
||||
$this->add_ix('HRD_IDX_COL_DXCC','`COL_DXCC`');
|
||||
$this->add_ix('HRD_IDX_COL_IOTA','`COL_IOTA`');
|
||||
$this->add_ix('HRD_IDX_COL_MODE','`COL_MODE`');
|
||||
$this->add_ix('HRD_IDX_COL_PFX','`COL_PFX`');
|
||||
$this->add_ix('HRD_IDX_COL_TIME_ON','`COL_TIME_ON`');
|
||||
}
|
||||
|
||||
private function add_ix($index,$cols) {
|
||||
$ix_exist = $this->db->query("SHOW INDEX FROM ".$this->config->item('table_name')." WHERE Key_name = '".$index."'")->num_rows();
|
||||
if ($ix_exist == 0) {
|
||||
$sql = "ALTER TABLE ".$this->config->item('table_name')." ADD INDEX `".$index."` (".$cols.");";
|
||||
$this->db->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
private function rm_ix($index) {
|
||||
$ix_exist = $this->db->query("SHOW INDEX FROM ".$this->config->item('table_name')." WHERE Key_name = '".$index."'")->num_rows();
|
||||
if ($ix_exist >= 1) {
|
||||
$sql = "ALTER TABLE ".$this->config->item('table_name')." DROP INDEX `".$index."`;";
|
||||
$this->db->query($sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1617,23 +1617,23 @@ class Logbook_model extends CI_Model {
|
||||
return array();
|
||||
}
|
||||
|
||||
$this->db->select($this->config->item('table_name').'.*, station_profile.*, dxcc_entities.*, lotw_users.callsign, lotw_users.lastupload');
|
||||
$this->db->from($this->config->item('table_name'));
|
||||
if (empty($logbooks_locations_array)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
// remove anything thats duplicated based on COL_PRIMARY_KEY
|
||||
$this->db->distinct(''.$this->config->item('table_name').'.COL_PRIMARY_KEY');
|
||||
$this->db->select($this->config->item('table_name').'.*, station_profile.*, dxcc_entities.*, lotw_users.callsign, lotw_users.lastupload');
|
||||
$this->db->from($this->config->item('table_name'));
|
||||
|
||||
$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
|
||||
$this->db->join('dxcc_entities', $this->config->item('table_name').'.col_dxcc = dxcc_entities.adif', 'left');
|
||||
$this->db->join('lotw_users', 'lotw_users.callsign = '.$this->config->item('table_name').'.col_call', 'left outer');
|
||||
$this->db->where_in('station_profile.station_id', $logbooks_locations_array);
|
||||
$this->db->order_by(''.$this->config->item('table_name').'.COL_TIME_ON', "desc");
|
||||
$this->db->order_by(''.$this->config->item('table_name').'.COL_PRIMARY_KEY', "desc");
|
||||
$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
|
||||
$this->db->join('dxcc_entities', $this->config->item('table_name').'.col_dxcc = dxcc_entities.adif', 'left');
|
||||
$this->db->join('lotw_users', 'lotw_users.callsign = '.$this->config->item('table_name').'.col_call', 'left outer');
|
||||
$this->db->where_in($this->config->item('table_name').'.station_id', $logbooks_locations_array);
|
||||
$this->db->order_by(''.$this->config->item('table_name').'.COL_TIME_ON', "desc");
|
||||
|
||||
$this->db->limit($num);
|
||||
$this->db->offset($offset);
|
||||
$this->db->limit($num);
|
||||
$this->db->offset($offset);
|
||||
|
||||
return $this->db->get();
|
||||
return $this->db->get();
|
||||
}
|
||||
|
||||
function get_qso($id, $trusted = false) {
|
||||
@@ -1832,12 +1832,12 @@ class Logbook_model extends CI_Model {
|
||||
|
||||
$sql = "SELECT * FROM ( select * from " . $this->config->item('table_name'). "
|
||||
WHERE station_id IN(". $location_list .")
|
||||
order by col_time_on desc, col_primary_key desc
|
||||
order by col_time_on desc
|
||||
limit " . $num .
|
||||
") hrd
|
||||
JOIN station_profile ON station_profile.station_id = hrd.station_id
|
||||
LEFT JOIN dxcc_entities ON hrd.col_dxcc = dxcc_entities.adif
|
||||
order by col_time_on desc, col_primary_key desc";
|
||||
order by col_time_on desc";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ class VUCC extends CI_Model
|
||||
|
||||
$location_list = "'".implode("','",$logbooks_locations_array)."'";
|
||||
|
||||
$sql = "select col_vucc_grids
|
||||
$sql = "select distinct col_vucc_grids
|
||||
from " . $this->config->item('table_name') .
|
||||
" where station_id in (" . $location_list . ")" .
|
||||
" and col_vucc_grids <> '' ";
|
||||
|
||||
Reference in New Issue
Block a user