Merge pull request #2096 from phl0/fixQsoViewForStationDxccNone

Use LEFT JOIN and COALESCE for station country
This commit is contained in:
Andreas Kristiansen
2023-04-28 15:32:07 +02:00
committed by GitHub
5 changed files with 17 additions and 16 deletions

View File

@@ -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->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();
}
@@ -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('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();
}
@@ -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->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();
}
@@ -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->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();
}
@@ -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->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();
}

View File

@@ -65,7 +65,7 @@ class Clublog_model extends CI_Model {
function get_clublog_qsos($station_id){
$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('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->group_start();
$this->db->where("COL_CLUBLOG_QSO_UPLOAD_STATUS", null);

View File

@@ -295,7 +295,7 @@ class Logbook_model extends CI_Model {
public function check_station($id){
$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);
$query = $this->db->get('station_profile');
@@ -1296,10 +1296,11 @@ class Logbook_model extends CI_Model {
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.*, 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->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('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);
return $this->db->get();
@@ -1311,7 +1312,7 @@ class Logbook_model extends CI_Model {
function get_qrz_qsos($station_id){
$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 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 .
' and (COL_QRZCOM_QSO_UPLOAD_STATUS is NULL
or COL_QRZCOM_QSO_UPLOAD_STATUS = ""
@@ -1331,7 +1332,7 @@ class Logbook_model extends CI_Model {
FROM %s qsos
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 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
AND qsos.COL_SAT_NAME = 'QO-100'
AND webadif.upload_date IS NULL
@@ -3183,7 +3184,7 @@ class Logbook_model extends CI_Model {
if($station_id != "0") {
$this->db->select('station_profile.*, dxcc_entities.name as station_country');
$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');
if ($station_result->num_rows() > 0){

View File

@@ -122,7 +122,7 @@ class Logbookadvanced_model extends CI_Model {
SELECT *, dxcc_entities.name AS station_country
FROM " . $this->config->item('table_name') . " qsos
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
ORDER BY qsos.COL_TIME_ON desc

View File

@@ -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->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('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->where('station_profile.user_id', $this->session->userdata('user_id'));
$this->db->or_where('station_profile.user_id =', NULL);
@@ -19,14 +19,14 @@ class Stations extends CI_Model {
function all() {
$this->db->select('station_profile.*, dxcc_entities.name as station_country');
$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();
}
function all_of_user() {
$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->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');
}
@@ -264,7 +264,7 @@ class Stations extends CI_Model {
$this->db->select('station_profile.*, dxcc_entities.name as station_country');
$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');
$row = $query->row();