Merge pull request #2096 from phl0/fixQsoViewForStationDxccNone

Use LEFT JOIN and COALESCE for station country
这个提交包含在:
Andreas Kristiansen 2023-04-28 15:32:07 +02:00 提交者 GitHub
当前提交 d247cdc37e
找不到此签名对应的密钥
GPG 密钥 ID: 4AEE18F83AFDEB23
共有 5 个文件被更改,包括 17 次插入16 次删除

查看文件

@ -50,7 +50,7 @@ class adif_data extends CI_Model {
$this->db->order_by($this->config->item('table_name').".COL_TIME_ON", "ASC"); $this->db->order_by($this->config->item('table_name').".COL_TIME_ON", "ASC");
$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id'); $this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
$this->db->join('dxcc_entities', 'station_profile.station_dxcc = dxcc_entities.adif'); $this->db->join('dxcc_entities', 'station_profile.station_dxcc = dxcc_entities.adif', 'left outer');
return $this->db->get(); return $this->db->get();
} }
@ -71,7 +71,7 @@ class adif_data extends CI_Model {
$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id'); $this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
$this->db->join('dxcc_entities', 'station_profile.station_dxcc = dxcc_entities.adif'); $this->db->join('dxcc_entities', 'station_profile.station_dxcc = dxcc_entities.adif', 'left outer');
return $this->db->get(); return $this->db->get();
} }
@ -109,7 +109,7 @@ class adif_data extends CI_Model {
$this->db->order_by($this->config->item('table_name').".COL_TIME_ON", "ASC"); $this->db->order_by($this->config->item('table_name').".COL_TIME_ON", "ASC");
$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id'); $this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
$this->db->join('dxcc_entities', 'station_profile.station_dxcc = dxcc_entities.adif'); $this->db->join('dxcc_entities', 'station_profile.station_dxcc = dxcc_entities.adif', 'left outer');
return $this->db->get(); return $this->db->get();
} }
@ -130,7 +130,7 @@ class adif_data extends CI_Model {
$this->db->order_by($this->config->item('table_name').".COL_TIME_ON", "ASC"); $this->db->order_by($this->config->item('table_name').".COL_TIME_ON", "ASC");
$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id'); $this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
$this->db->join('dxcc_entities', 'station_profile.station_dxcc = dxcc_entities.adif'); $this->db->join('dxcc_entities', 'station_profile.station_dxcc = dxcc_entities.adif', 'left outer');
return $this->db->get(); return $this->db->get();
} }
@ -158,7 +158,7 @@ class adif_data extends CI_Model {
$this->db->order_by($this->config->item('table_name').".COL_TIME_ON", "ASC"); $this->db->order_by($this->config->item('table_name').".COL_TIME_ON", "ASC");
$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id'); $this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
$this->db->join('dxcc_entities', 'station_profile.station_dxcc = dxcc_entities.adif'); $this->db->join('dxcc_entities', 'station_profile.station_dxcc = dxcc_entities.adif', 'left outer');
return $this->db->get(); return $this->db->get();
} }

查看文件

@ -65,7 +65,7 @@ class Clublog_model extends CI_Model {
function get_clublog_qsos($station_id){ function get_clublog_qsos($station_id){
$this->db->select('*, dxcc_entities.name as station_country'); $this->db->select('*, dxcc_entities.name as station_country');
$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id'); $this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
$this->db->join('dxcc_entities', 'station_profile.station_dxcc = dxcc_entities.adif', 'left'); $this->db->join('dxcc_entities', 'station_profile.station_dxcc = dxcc_entities.adif', 'left outer');
$this->db->where($this->config->item('table_name').'.station_id', $station_id); $this->db->where($this->config->item('table_name').'.station_id', $station_id);
$this->db->group_start(); $this->db->group_start();
$this->db->where("COL_CLUBLOG_QSO_UPLOAD_STATUS", null); $this->db->where("COL_CLUBLOG_QSO_UPLOAD_STATUS", null);

查看文件

@ -295,7 +295,7 @@ class Logbook_model extends CI_Model {
public function check_station($id){ public function check_station($id){
$this->db->select('station_profile.*, dxcc_entities.name as station_country'); $this->db->select('station_profile.*, dxcc_entities.name as station_country');
$this->db->join('dxcc_entities','station_profile.station_dxcc = dxcc_entities.adif','left'); $this->db->join('dxcc_entities','station_profile.station_dxcc = dxcc_entities.adif','left outer');
$this->db->where('station_id', $id); $this->db->where('station_id', $id);
$query = $this->db->get('station_profile'); $query = $this->db->get('station_profile');
@ -1296,10 +1296,11 @@ class Logbook_model extends CI_Model {
function get_qso($id) { function get_qso($id) {
$this->db->select($this->config->item('table_name').'.*, station_profile.*, dxcc_entities.*, dxcc_entities_2.name as station_country, dxcc_entities_2.end as station_end'); $this->db->select($this->config->item('table_name').'.*, station_profile.*, dxcc_entities.*, dxcc_entities_2.name as station_country, dxcc_entities_2.end as station_end');
$this->db->select($this->config->item('table_name').'.*, station_profile.*, dxcc_entities.*, coalesce(dxcc_entities_2.name, "None") as station_country, dxcc_entities_2.end as station_end');
$this->db->from($this->config->item('table_name')); $this->db->from($this->config->item('table_name'));
$this->db->join('dxcc_entities', $this->config->item('table_name').'.col_dxcc = dxcc_entities.adif', 'left'); $this->db->join('dxcc_entities', $this->config->item('table_name').'.col_dxcc = dxcc_entities.adif', 'left');
$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id', 'left'); $this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id', 'left');
$this->db->join('dxcc_entities as dxcc_entities_2', 'station_profile.station_dxcc = dxcc_entities_2.adif'); $this->db->join('dxcc_entities as dxcc_entities_2', 'station_profile.station_dxcc = dxcc_entities_2.adif', 'left outer');
$this->db->where('COL_PRIMARY_KEY', $id); $this->db->where('COL_PRIMARY_KEY', $id);
return $this->db->get(); return $this->db->get();
@ -1311,7 +1312,7 @@ class Logbook_model extends CI_Model {
function get_qrz_qsos($station_id){ function get_qrz_qsos($station_id){
$sql = 'select *, dxcc_entities.name as station_country from ' . $this->config->item('table_name') . ' thcv ' . $sql = 'select *, dxcc_entities.name as station_country from ' . $this->config->item('table_name') . ' thcv ' .
' left join station_profile on thcv.station_id = station_profile.station_id' . ' left join station_profile on thcv.station_id = station_profile.station_id' .
' left join dxcc_entities on thcv.col_my_dxcc = dxcc_entities.adif' . ' left outer join dxcc_entities on thcv.col_my_dxcc = dxcc_entities.adif' .
' where thcv.station_id = ' . $station_id . ' where thcv.station_id = ' . $station_id .
' and (COL_QRZCOM_QSO_UPLOAD_STATUS is NULL ' and (COL_QRZCOM_QSO_UPLOAD_STATUS is NULL
or COL_QRZCOM_QSO_UPLOAD_STATUS = "" or COL_QRZCOM_QSO_UPLOAD_STATUS = ""
@ -1331,7 +1332,7 @@ class Logbook_model extends CI_Model {
FROM %s qsos FROM %s qsos
INNER JOIN station_profile ON qsos.station_id = station_profile.station_id INNER JOIN station_profile ON qsos.station_id = station_profile.station_id
LEFT JOIN dxcc_entities on qsos.col_my_dxcc = dxcc_entities.adif LEFT JOIN dxcc_entities on qsos.col_my_dxcc = dxcc_entities.adif
LEFT JOIN webadif ON qsos.COL_PRIMARY_KEY = webadif.qso_id LEFT OUTER JOIN webadif ON qsos.COL_PRIMARY_KEY = webadif.qso_id
WHERE qsos.station_id = %d WHERE qsos.station_id = %d
AND qsos.COL_SAT_NAME = 'QO-100' AND qsos.COL_SAT_NAME = 'QO-100'
AND webadif.upload_date IS NULL AND webadif.upload_date IS NULL
@ -3183,7 +3184,7 @@ class Logbook_model extends CI_Model {
if($station_id != "0") { if($station_id != "0") {
$this->db->select('station_profile.*, dxcc_entities.name as station_country'); $this->db->select('station_profile.*, dxcc_entities.name as station_country');
$this->db->where('station_id', $station_id); $this->db->where('station_id', $station_id);
$this->db->join('dxcc_entities', 'station_profile.station_dxcc = dxcc_entities.adif'); $this->db->join('dxcc_entities', 'station_profile.station_dxcc = dxcc_entities.adif', 'left outer');
$station_result = $this->db->get('station_profile'); $station_result = $this->db->get('station_profile');
if ($station_result->num_rows() > 0){ if ($station_result->num_rows() > 0){

查看文件

@ -122,7 +122,7 @@ class Logbookadvanced_model extends CI_Model {
SELECT *, dxcc_entities.name AS station_country SELECT *, dxcc_entities.name AS station_country
FROM " . $this->config->item('table_name') . " qsos FROM " . $this->config->item('table_name') . " qsos
INNER JOIN station_profile ON qsos.station_id = station_profile.station_id INNER JOIN station_profile ON qsos.station_id = station_profile.station_id
INNER JOIN dxcc_entities ON qsos.COL_MY_DXCC = dxcc_entities.adif LEFT OUTER JOIN dxcc_entities ON qsos.COL_MY_DXCC = dxcc_entities.adif
WHERE station_profile.user_id = ? WHERE station_profile.user_id = ?
$where $where
ORDER BY qsos.COL_TIME_ON desc ORDER BY qsos.COL_TIME_ON desc

查看文件

@ -7,7 +7,7 @@ class Stations extends CI_Model {
$this->db->select('station_profile.*, dxcc_entities.name as station_country, dxcc_entities.end as dxcc_end, count('.$this->config->item('table_name').'.station_id) as qso_total'); $this->db->select('station_profile.*, dxcc_entities.name as station_country, dxcc_entities.end as dxcc_end, count('.$this->config->item('table_name').'.station_id) as qso_total');
$this->db->from('station_profile'); $this->db->from('station_profile');
$this->db->join($this->config->item('table_name'),'station_profile.station_id = '.$this->config->item('table_name').'.station_id','left'); $this->db->join($this->config->item('table_name'),'station_profile.station_id = '.$this->config->item('table_name').'.station_id','left');
$this->db->join('dxcc_entities','station_profile.station_dxcc = dxcc_entities.adif','left'); $this->db->join('dxcc_entities','station_profile.station_dxcc = dxcc_entities.adif','left outer');
$this->db->group_by('station_profile.station_id'); $this->db->group_by('station_profile.station_id');
$this->db->where('station_profile.user_id', $this->session->userdata('user_id')); $this->db->where('station_profile.user_id', $this->session->userdata('user_id'));
$this->db->or_where('station_profile.user_id =', NULL); $this->db->or_where('station_profile.user_id =', NULL);
@ -19,14 +19,14 @@ class Stations extends CI_Model {
function all() { function all() {
$this->db->select('station_profile.*, dxcc_entities.name as station_country'); $this->db->select('station_profile.*, dxcc_entities.name as station_country');
$this->db->from('station_profile'); $this->db->from('station_profile');
$this->db->join('dxcc_entities','station_profile.station_dxcc = dxcc_entities.adif','left'); $this->db->join('dxcc_entities','station_profile.station_dxcc = dxcc_entities.adif','left outer');
return $this->db->get(); return $this->db->get();
} }
function all_of_user() { function all_of_user() {
$this->db->select('station_profile.*, dxcc_entities.name as station_country, dxcc_entities.end as dxcc_end'); $this->db->select('station_profile.*, dxcc_entities.name as station_country, dxcc_entities.end as dxcc_end');
$this->db->where('user_id', $this->session->userdata('user_id')); $this->db->where('user_id', $this->session->userdata('user_id'));
$this->db->join('dxcc_entities','station_profile.station_dxcc = dxcc_entities.adif','left'); $this->db->join('dxcc_entities','station_profile.station_dxcc = dxcc_entities.adif','left outer');
return $this->db->get('station_profile'); return $this->db->get('station_profile');
} }
@ -264,7 +264,7 @@ class Stations extends CI_Model {
$this->db->select('station_profile.*, dxcc_entities.name as station_country'); $this->db->select('station_profile.*, dxcc_entities.name as station_country');
$this->db->where('station_id', $clean_id); $this->db->where('station_id', $clean_id);
$this->db->join('dxcc_entities', 'station_profile.station_dxcc = dxcc_entities.adif'); $this->db->join('dxcc_entities', 'station_profile.station_dxcc = dxcc_entities.adif', 'left outer');
$query = $this->db->get('station_profile'); $query = $this->db->get('station_profile');
$row = $query->row(); $row = $query->row();