kopia lustrzana https://github.com/magicbug/Cloudlog
Merge pull request #1169 from AndreasK79/accumulated_station_logbooks
[Accumulated Statistics] Updated code to support station logbookspull/1172/head
commit
ddccc622b1
|
@ -11,31 +11,33 @@ class Accumulate_model extends CI_Model
|
|||
|
||||
function get_accumulated_data($band, $award, $mode, $period) {
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('Stations');
|
||||
$station_id = $CI->Stations->find_active();
|
||||
$CI->load->model('logbooks_model');
|
||||
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||
|
||||
$location_list = "'".implode("','",$logbooks_locations_array)."'";
|
||||
|
||||
switch ($award) {
|
||||
case 'dxcc': $result = $this->get_accumulated_dxcc($band, $mode, $period, $station_id); break;
|
||||
case 'was': $result = $this->get_accumulated_was($band, $mode, $period, $station_id); break;
|
||||
case 'iota': $result = $this->get_accumulated_iota($band, $mode, $period, $station_id); break;
|
||||
case 'waz': $result = $this->get_accumulated_waz($band, $mode, $period, $station_id); break;
|
||||
case 'dxcc': $result = $this->get_accumulated_dxcc($band, $mode, $period, $location_list); break;
|
||||
case 'was': $result = $this->get_accumulated_was($band, $mode, $period, $location_list); break;
|
||||
case 'iota': $result = $this->get_accumulated_iota($band, $mode, $period, $location_list); break;
|
||||
case 'waz': $result = $this->get_accumulated_waz($band, $mode, $period, $location_list); break;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function get_accumulated_dxcc($band, $mode, $period, $station_id) {
|
||||
function get_accumulated_dxcc($band, $mode, $period, $location_list) {
|
||||
if ($period == "year") {
|
||||
$sql = "SELECT year(col_time_on) as year,
|
||||
(select count(distinct b.col_dxcc) from " .
|
||||
$this->config->item('table_name') .
|
||||
" as b where year(col_time_on) <= year and b.station_id = ". $station_id;
|
||||
" as b where year(col_time_on) <= year and b.station_id in (". $location_list . ")";
|
||||
}
|
||||
else if ($period == "month") {
|
||||
$sql = "SELECT date_format(col_time_on, '%Y%m') as year,
|
||||
(select count(distinct b.col_dxcc) from " .
|
||||
$this->config->item('table_name') .
|
||||
" as b where date_format(col_time_on, '%Y%m') <= year and b.station_id = ". $station_id;
|
||||
" as b where date_format(col_time_on, '%Y%m') <= year and b.station_id in (". $location_list . ")";
|
||||
}
|
||||
|
||||
if ($band != 'All') {
|
||||
|
@ -48,11 +50,11 @@ class Accumulate_model extends CI_Model
|
|||
}
|
||||
|
||||
if ($mode != 'All') {
|
||||
$sql .= " and col_mode ='" . $mode . "'";
|
||||
$sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')";
|
||||
}
|
||||
|
||||
$sql .=") total from " . $this->config->item('table_name') . " as a
|
||||
where a.station_id = ". $station_id;
|
||||
$sql .=" and b.col_dxcc > 0) total from " . $this->config->item('table_name') . " as a
|
||||
where a.station_id in (". $location_list . ")";
|
||||
|
||||
if ($band != 'All') {
|
||||
if ($band == 'SAT') {
|
||||
|
@ -64,9 +66,11 @@ class Accumulate_model extends CI_Model
|
|||
}
|
||||
|
||||
if ($mode != 'All') {
|
||||
$sql .= " and col_mode ='" . $mode . "'";
|
||||
$sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')";
|
||||
}
|
||||
|
||||
$sql .= " and col_dxcc > 0";
|
||||
|
||||
if ($period == "year") {
|
||||
$sql .= " group by year(a.col_time_on)
|
||||
order by year(a.col_time_on)";
|
||||
|
@ -81,18 +85,18 @@ class Accumulate_model extends CI_Model
|
|||
return $query->result();
|
||||
}
|
||||
|
||||
function get_accumulated_was($band, $mode, $period, $station_id) {
|
||||
function get_accumulated_was($band, $mode, $period, $location_list) {
|
||||
if ($period == "year") {
|
||||
$sql = "SELECT year(col_time_on) as year,
|
||||
(select count(distinct b.col_state) from " .
|
||||
$this->config->item('table_name') .
|
||||
" as b where year(col_time_on) <= year and b.station_id = ". $station_id;
|
||||
" as b where year(col_time_on) <= year and b.station_id in (". $location_list . ")";
|
||||
}
|
||||
else if ($period == "month") {
|
||||
$sql = "SELECT date_format(col_time_on, '%Y%m') as year,
|
||||
(select count(distinct b.col_state) from " .
|
||||
$this->config->item('table_name') .
|
||||
" as b where date_format(col_time_on, '%Y%m') <= year and b.station_id = ". $station_id;
|
||||
" as b where date_format(col_time_on, '%Y%m') <= year and b.station_id in (". $location_list . ")";
|
||||
}
|
||||
|
||||
if ($band != 'All') {
|
||||
|
@ -105,14 +109,14 @@ class Accumulate_model extends CI_Model
|
|||
}
|
||||
|
||||
if ($mode != 'All') {
|
||||
$sql .= " and col_mode ='" . $mode . "'";
|
||||
$sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')";
|
||||
}
|
||||
|
||||
$sql .= " and COL_DXCC in ('291', '6', '110')";
|
||||
$sql .= " and COL_STATE in ('AK','AL','AR','AZ','CA','CO','CT','DE','FL','GA','HI','IA','ID','IL','IN','KS','KY','LA','MA','MD','ME','MI','MN','MO','MS','MT','NC','ND','NE','NH','NJ','NM','NV','NY','OH','OK','OR','PA','RI','SC','SD','TN','TX','UT','VA','VT','WA','WI','WV','WY')";
|
||||
|
||||
$sql .=") total from " . $this->config->item('table_name') . " as a
|
||||
where a.station_id = ". $station_id;
|
||||
where a.station_id in (". $location_list . ")";
|
||||
|
||||
if ($band != 'All') {
|
||||
if ($band == 'SAT') {
|
||||
|
@ -124,7 +128,7 @@ class Accumulate_model extends CI_Model
|
|||
}
|
||||
|
||||
if ($mode != 'All') {
|
||||
$sql .= " and col_mode ='" . $mode . "'";
|
||||
$sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')";
|
||||
}
|
||||
|
||||
$sql .= " and COL_DXCC in ('291', '6', '110')";
|
||||
|
@ -144,18 +148,18 @@ class Accumulate_model extends CI_Model
|
|||
return $query->result();
|
||||
}
|
||||
|
||||
function get_accumulated_iota($band, $mode, $period, $station_id) {
|
||||
function get_accumulated_iota($band, $mode, $period, $location_list) {
|
||||
if ($period == "year") {
|
||||
$sql = "SELECT year(col_time_on) as year,
|
||||
(select count(distinct b.col_iota) from " .
|
||||
$this->config->item('table_name') .
|
||||
" as b where year(col_time_on) <= year and b.station_id = ". $station_id;
|
||||
" as b where year(col_time_on) <= year and b.station_id in (". $location_list . ")";
|
||||
}
|
||||
else if ($period == "month") {
|
||||
$sql = "SELECT date_format(col_time_on, '%Y%m') as year,
|
||||
(select count(distinct b.col_iota) from " .
|
||||
$this->config->item('table_name') .
|
||||
" as b where date_format(col_time_on, '%Y%m') <= year and b.station_id = ". $station_id;
|
||||
" as b where date_format(col_time_on, '%Y%m') <= year and b.station_id in (". $location_list . ")";
|
||||
}
|
||||
|
||||
if ($band != 'All') {
|
||||
|
@ -168,11 +172,11 @@ class Accumulate_model extends CI_Model
|
|||
}
|
||||
|
||||
if ($mode != 'All') {
|
||||
$sql .= " and col_mode ='" . $mode . "'";
|
||||
$sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')";
|
||||
}
|
||||
|
||||
$sql .=") total from " . $this->config->item('table_name') . " as a
|
||||
where a.station_id = ". $station_id;
|
||||
where a.station_id in (". $location_list . ")";
|
||||
|
||||
if ($band != 'All') {
|
||||
if ($band == 'SAT') {
|
||||
|
@ -184,7 +188,7 @@ class Accumulate_model extends CI_Model
|
|||
}
|
||||
|
||||
if ($mode != 'All') {
|
||||
$sql .= " and col_mode ='" . $mode . "'";
|
||||
$sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')";
|
||||
}
|
||||
|
||||
if ($period == "year") {
|
||||
|
@ -201,18 +205,18 @@ class Accumulate_model extends CI_Model
|
|||
return $query->result();
|
||||
}
|
||||
|
||||
function get_accumulated_waz($band, $mode, $period, $station_id) {
|
||||
function get_accumulated_waz($band, $mode, $period, $location_list) {
|
||||
if ($period == "year") {
|
||||
$sql = "SELECT year(col_time_on) as year,
|
||||
(select count(distinct b.col_cqz) from " .
|
||||
$this->config->item('table_name') .
|
||||
" as b where year(col_time_on) <= year and b.station_id = ". $station_id;
|
||||
" as b where year(col_time_on) <= year and b.station_id in (". $location_list . ")";
|
||||
}
|
||||
else if ($period == "month") {
|
||||
$sql = "SELECT date_format(col_time_on, '%Y%m') as year,
|
||||
(select count(distinct b.col_cqz) from " .
|
||||
$this->config->item('table_name') .
|
||||
" as b where date_format(col_time_on, '%Y%m') <= year and b.station_id = ". $station_id;
|
||||
" as b where date_format(col_time_on, '%Y%m') <= year and b.station_id in (". $location_list . ")";
|
||||
}
|
||||
|
||||
if ($band != 'All') {
|
||||
|
@ -225,11 +229,11 @@ class Accumulate_model extends CI_Model
|
|||
}
|
||||
|
||||
if ($mode != 'All') {
|
||||
$sql .= " and col_mode ='" . $mode . "'";
|
||||
$sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')";
|
||||
}
|
||||
|
||||
$sql .=") total from " . $this->config->item('table_name') . " as a
|
||||
where a.station_id = ". $station_id;
|
||||
where a.station_id in (". $location_list . ")";
|
||||
|
||||
if ($band != 'All') {
|
||||
if ($band == 'SAT') {
|
||||
|
@ -241,7 +245,7 @@ class Accumulate_model extends CI_Model
|
|||
}
|
||||
|
||||
if ($mode != 'All') {
|
||||
$sql .= " and col_mode ='" . $mode . "'";
|
||||
$sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')";
|
||||
}
|
||||
|
||||
if ($period == "year") {
|
||||
|
@ -260,11 +264,13 @@ class Accumulate_model extends CI_Model
|
|||
|
||||
function get_worked_bands() {
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('Stations');
|
||||
$station_id = $CI->Stations->find_active();
|
||||
$CI->load->model('logbooks_model');
|
||||
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||
|
||||
$location_list = "'".implode("','",$logbooks_locations_array)."'";
|
||||
|
||||
$data = $this->db->query(
|
||||
"SELECT distinct LOWER(`COL_BAND`) as `COL_BAND` FROM `" . $this->config->item('table_name') . "` WHERE station_id = " . $station_id . " AND COL_PROP_MODE != \"SAT\""
|
||||
"SELECT distinct LOWER(`COL_BAND`) as `COL_BAND` FROM `" . $this->config->item('table_name') . "` WHERE station_id in (" . $location_list . ") AND COL_PROP_MODE != \"SAT\""
|
||||
);
|
||||
$worked_slots = array();
|
||||
foreach ($data->result() as $row) {
|
||||
|
@ -272,7 +278,7 @@ class Accumulate_model extends CI_Model
|
|||
}
|
||||
|
||||
$SAT_data = $this->db->query(
|
||||
"SELECT distinct LOWER(`COL_PROP_MODE`) as `COL_PROP_MODE` FROM `" . $this->config->item('table_name') . "` WHERE station_id = " . $station_id . " AND COL_PROP_MODE = \"SAT\""
|
||||
"SELECT distinct LOWER(`COL_PROP_MODE`) as `COL_PROP_MODE` FROM `" . $this->config->item('table_name') . "` WHERE station_id in (" . $location_list . ") AND COL_PROP_MODE = \"SAT\""
|
||||
);
|
||||
|
||||
foreach ($SAT_data->result() as $row) {
|
||||
|
|
Ładowanie…
Reference in New Issue