kopia lustrzana https://github.com/magicbug/Cloudlog
[Dashboard] More optimisation for speed now 70% faster
rodzic
c44b4d7e4b
commit
3a83145e09
|
@ -20,6 +20,9 @@ class Dashboard extends CI_Controller {
|
|||
redirect('user/login');
|
||||
}
|
||||
|
||||
$this->load->model('logbooks_model');
|
||||
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||
|
||||
// Calculate Lat/Lng from Locator to use on Maps
|
||||
if($this->session->userdata('user_locator')) {
|
||||
$this->load->library('qra');
|
||||
|
@ -51,37 +54,39 @@ class Dashboard extends CI_Controller {
|
|||
$data['radio_status'] = $this->cat->recent_status();
|
||||
|
||||
// Store info
|
||||
$data['todays_qsos'] = $this->logbook_model->todays_qsos();
|
||||
$data['total_qsos'] = $this->logbook_model->total_qsos();
|
||||
$data['month_qsos'] = $this->logbook_model->month_qsos();
|
||||
$data['year_qsos'] = $this->logbook_model->year_qsos();
|
||||
$data['todays_qsos'] = $this->logbook_model->todays_qsos($logbooks_locations_array);
|
||||
$data['total_qsos'] = $this->logbook_model->total_qsos($logbooks_locations_array);
|
||||
$data['month_qsos'] = $this->logbook_model->month_qsos($logbooks_locations_array);
|
||||
$data['year_qsos'] = $this->logbook_model->year_qsos($logbooks_locations_array);
|
||||
|
||||
// Load Countries Breakdown data into array
|
||||
$CountriesBreakdown = $this->logbook_model->total_countries_confirmed();
|
||||
$CountriesBreakdown = $this->logbook_model->total_countries_confirmed($logbooks_locations_array);
|
||||
|
||||
$data['total_countries'] = $CountriesBreakdown['Countries_Worked'];
|
||||
$data['total_countries_confirmed_paper'] = $CountriesBreakdown['Countries_Worked_QSL'];
|
||||
$data['total_countries_confirmed_eqsl'] = $CountriesBreakdown['Countries_Worked_EQSL'];
|
||||
$data['total_countries_confirmed_lotw'] = $CountriesBreakdown['Countries_Worked_LOTW'];
|
||||
|
||||
$data['total_qsl_sent'] = $this->logbook_model->total_qsl_sent();
|
||||
$data['total_qsl_recv'] = $this->logbook_model->total_qsl_recv();
|
||||
$data['total_qsl_requested'] = $this->logbook_model->total_qsl_requested();
|
||||
$QSLStatsBreakdownArray =$this->logbook_model->get_QSLStats($logbooks_locations_array);
|
||||
|
||||
$data['total_eqsl_sent'] = $this->logbook_model->total_eqsl_sent();
|
||||
$data['total_eqsl_recv'] = $this->logbook_model->total_eqsl_recv();
|
||||
$data['total_qsl_sent'] = $QSLStatsBreakdownArray['QSL_Sent'];
|
||||
$data['total_qsl_recv'] = $QSLStatsBreakdownArray['QSL_Received'];
|
||||
$data['total_qsl_requested'] = $QSLStatsBreakdownArray['QSL_Requested'];
|
||||
|
||||
$data['total_lotw_sent'] = $this->logbook_model->total_lotw_sent();
|
||||
$data['total_lotw_recv'] = $this->logbook_model->total_lotw_recv();
|
||||
$data['total_eqsl_sent'] = $QSLStatsBreakdownArray['eQSL_Sent'];
|
||||
$data['total_eqsl_recv'] = $QSLStatsBreakdownArray['eQSL_Received'];
|
||||
|
||||
$data['last_five_qsos'] = $this->logbook_model->get_last_qsos('18');
|
||||
$data['total_lotw_sent'] = $QSLStatsBreakdownArray['LoTW_Sent'];
|
||||
$data['total_lotw_recv'] = $QSLStatsBreakdownArray['LoTW_Received'];
|
||||
|
||||
$data['last_five_qsos'] = $this->logbook_model->get_last_qsos('18', $logbooks_locations_array);
|
||||
|
||||
$data['page_title'] = "Dashboard";
|
||||
|
||||
$this->load->model('dxcc');
|
||||
$dxcc = $this->dxcc->list_current();
|
||||
|
||||
$current = $this->logbook_model->total_countries_current();
|
||||
$current = $this->logbook_model->total_countries_current($logbooks_locations_array);
|
||||
|
||||
$data['total_countries_needed'] = count($dxcc->result()) - $current;
|
||||
|
||||
|
|
|
@ -992,11 +992,15 @@ class Logbook_model extends CI_Model {
|
|||
}
|
||||
}
|
||||
|
||||
function get_last_qsos($num) {
|
||||
function get_last_qsos($num, $StationLocationsArray = null) {
|
||||
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('logbooks_model');
|
||||
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||
if($StationLocationsArray == null) {
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('logbooks_model');
|
||||
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||
} else {
|
||||
$logbooks_locations_array = $StationLocationsArray;
|
||||
}
|
||||
|
||||
if ($logbooks_locations_array) {
|
||||
//$this->db->select('COL_CALL, COL_BAND, COL_TIME_ON, COL_RST_RCVD, COL_RST_SENT, COL_MODE, COL_SUBMODE, COL_NAME, COL_COUNTRY, COL_PRIMARY_KEY, COL_SAT_NAME, COL_STX_STRING, COL_SRX_STRING, COL_IOTA, COL_STATE, COL_GRIDSQUARE');
|
||||
|
@ -1105,10 +1109,14 @@ class Logbook_model extends CI_Model {
|
|||
}
|
||||
|
||||
/* Return total number of qsos */
|
||||
function total_qsos() {
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('logbooks_model');
|
||||
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||
function total_qsos($StationLocationsArray = null) {
|
||||
if($StationLocationsArray == null) {
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('logbooks_model');
|
||||
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||
} else {
|
||||
$logbooks_locations_array = $StationLocationsArray;
|
||||
}
|
||||
|
||||
if ($logbooks_locations_array) {
|
||||
$this->db->select('COUNT( * ) as count', FALSE);
|
||||
|
@ -1128,10 +1136,14 @@ class Logbook_model extends CI_Model {
|
|||
}
|
||||
|
||||
/* Return number of QSOs had today */
|
||||
function todays_qsos() {
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('logbooks_model');
|
||||
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||
function todays_qsos($StationLocationsArray = null) {
|
||||
if($StationLocationsArray == null) {
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('logbooks_model');
|
||||
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||
} else {
|
||||
$logbooks_locations_array = $StationLocationsArray;
|
||||
}
|
||||
|
||||
if ($logbooks_locations_array) {
|
||||
$morning = date('Y-m-d 00:00:00');
|
||||
|
@ -1215,11 +1227,14 @@ class Logbook_model extends CI_Model {
|
|||
}
|
||||
|
||||
// Return QSOs made during the current month
|
||||
function month_qsos() {
|
||||
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('logbooks_model');
|
||||
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||
function month_qsos($StationLocationsArray = null) {
|
||||
if($StationLocationsArray == null) {
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('logbooks_model');
|
||||
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||
} else {
|
||||
$logbooks_locations_array = $StationLocationsArray;
|
||||
}
|
||||
|
||||
if ($logbooks_locations_array) {
|
||||
|
||||
|
@ -1263,11 +1278,15 @@ class Logbook_model extends CI_Model {
|
|||
|
||||
|
||||
/* Return QSOs made during the current Year */
|
||||
function year_qsos() {
|
||||
function year_qsos($StationLocationsArray = null) {
|
||||
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('logbooks_model');
|
||||
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||
if($StationLocationsArray == null) {
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('logbooks_model');
|
||||
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||
} else {
|
||||
$logbooks_locations_array = $StationLocationsArray;
|
||||
}
|
||||
|
||||
if ($logbooks_locations_array) {
|
||||
|
||||
|
@ -1448,6 +1467,53 @@ class Logbook_model extends CI_Model {
|
|||
return $query;
|
||||
}
|
||||
|
||||
function get_QSLStats($StationLocationsArray = null) {
|
||||
|
||||
if($StationLocationsArray == null) {
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('logbooks_model');
|
||||
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||
} else {
|
||||
$logbooks_locations_array = $StationLocationsArray;
|
||||
}
|
||||
|
||||
if(!empty($logbooks_locations_array)) {
|
||||
$this->db->select('
|
||||
COUNT(IF(COL_QSL_SENT="Y",COL_QSL_SENT,null)) as QSL_Sent,
|
||||
COUNT(IF(COL_QSL_RCVD="Y",COL_QSL_RCVD,null)) as QSL_Received,
|
||||
COUNT(IF(COL_QSL_SENT IN("Q", "R") ,COL_QSL_SENT,null)) as QSL_Requested,
|
||||
COUNT(IF(COL_EQSL_QSL_SENT="Y",COL_EQSL_QSL_SENT,null)) as eQSL_Sent,
|
||||
COUNT(IF(COL_EQSL_QSL_RCVD="Y",COL_EQSL_QSL_RCVD,null)) as eQSL_Received,
|
||||
COUNT(IF(COL_LOTW_QSL_SENT="Y",COL_LOTW_QSL_SENT,null)) as LoTW_Sent,
|
||||
COUNT(IF(COL_LOTW_QSL_RCVD="Y",COL_LOTW_QSL_RCVD,null)) as LoTW_Received
|
||||
');
|
||||
$this->db->where_in('station_id', $logbooks_locations_array);
|
||||
|
||||
if ($query = $this->db->get($this->config->item('table_name')))
|
||||
{
|
||||
$this->db->last_query();
|
||||
foreach ($query->result() as $row)
|
||||
{
|
||||
$QSLBreakdown['QSL_Sent'] = $row->QSL_Sent;
|
||||
$QSLBreakdown['QSL_Received'] = $row->QSL_Received;
|
||||
$QSLBreakdown['QSL_Requested'] = $row->QSL_Requested;
|
||||
$QSLBreakdown['eQSL_Sent'] = $row->eQSL_Sent;
|
||||
$QSLBreakdown['eQSL_Received'] = $row->eQSL_Received;
|
||||
$QSLBreakdown['LoTW_Sent'] = $row->LoTW_Sent;
|
||||
$QSLBreakdown['LoTW_Received'] = $row->LoTW_Received;
|
||||
}
|
||||
|
||||
return $QSLBreakdown;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* Return total number of QSL Cards sent */
|
||||
function total_qsl_sent() {
|
||||
$CI =& get_instance();
|
||||
|
@ -1643,10 +1709,14 @@ class Logbook_model extends CI_Model {
|
|||
}
|
||||
|
||||
/* Return total number of countries worked */
|
||||
function total_countries_current() {
|
||||
function total_countries_current($StationLocationsArray = null) {
|
||||
if($StationLocationsArray == null) {
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('logbooks_model');
|
||||
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||
} else {
|
||||
$logbooks_locations_array = $StationLocationsArray;
|
||||
}
|
||||
|
||||
if(!empty($logbooks_locations_array)) {
|
||||
$this->db->select('DISTINCT ('.$this->config->item('table_name').'.COL_COUNTRY)');
|
||||
|
@ -1670,7 +1740,7 @@ class Logbook_model extends CI_Model {
|
|||
$CI->load->model('logbooks_model');
|
||||
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||
} else {
|
||||
$logbooks_locations_array = StationLocationsArray;
|
||||
$logbooks_locations_array = $StationLocationsArray;
|
||||
}
|
||||
|
||||
if(!empty($logbooks_locations_array)) {
|
||||
|
|
Ładowanie…
Reference in New Issue