[Dashboard] Merged 4 SQL queries into one call reducing page load times.
这个提交包含在:
		
							父节点
							
								
									1b64410649
								
							
						
					
					
						当前提交
						c44b4d7e4b
					
				
					共有  2 个文件被更改,包括 48 次插入 和 4 次删除
				
			
		|  | @ -56,10 +56,13 @@ class Dashboard extends CI_Controller { | ||||||
| 			$data['month_qsos'] = $this->logbook_model->month_qsos(); | 			$data['month_qsos'] = $this->logbook_model->month_qsos(); | ||||||
| 			$data['year_qsos'] = $this->logbook_model->year_qsos(); | 			$data['year_qsos'] = $this->logbook_model->year_qsos(); | ||||||
| 
 | 
 | ||||||
| 			$data['total_countries'] = $this->logbook_model->total_countries(); | 			// Load  Countries Breakdown data into array
 | ||||||
| 			$data['total_countries_confirmed_paper'] = $this->logbook_model->total_countries_confirmed_paper(); | 			$CountriesBreakdown = $this->logbook_model->total_countries_confirmed(); | ||||||
| 			$data['total_countries_confirmed_eqsl'] = $this->logbook_model->total_countries_confirmed_eqsl(); | 
 | ||||||
| 			$data['total_countries_confirmed_lotw'] = $this->logbook_model->total_countries_confirmed_lotw(); | 			$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_sent'] = $this->logbook_model->total_qsl_sent(); | ||||||
| 			$data['total_qsl_recv'] = $this->logbook_model->total_qsl_recv(); | 			$data['total_qsl_recv'] = $this->logbook_model->total_qsl_recv(); | ||||||
|  |  | ||||||
|  | @ -1662,6 +1662,47 @@ class Logbook_model extends CI_Model { | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |         /* Return total number of countries confirmed with along with qsl types confirmed */ | ||||||
|  |         function total_countries_confirmed($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(DISTINCT COL_COUNTRY) as Countries_Worked, | ||||||
|  |             COUNT(DISTINCT IF(COL_QSL_RCVD = "Y", COL_COUNTRY, NULL)) as Countries_Worked_QSL, | ||||||
|  |             COUNT(DISTINCT IF(COL_EQSL_QSL_RCVD = "Y", COL_COUNTRY, NULL)) as Countries_Worked_EQSL,   | ||||||
|  |             COUNT(DISTINCT IF(COL_LOTW_QSL_RCVD = "Y", COL_COUNTRY, NULL)) as Countries_Worked_LOTW'); | ||||||
|  |             $this->db->where_in('station_id', $logbooks_locations_array); | ||||||
|  |             $this->db->where('COL_COUNTRY !=', 'Invalid'); | ||||||
|  |             $this->db->where('COL_DXCC >', '0'); | ||||||
|  | 
 | ||||||
|  |             if ($query = $this->db->get($this->config->item('table_name'))) | ||||||
|  |             { | ||||||
|  |                 foreach ($query->result() as $row) | ||||||
|  |                 { | ||||||
|  |                         $CountriesBreakdown['Countries_Worked'] = $row->Countries_Worked; | ||||||
|  |                         $CountriesBreakdown['Countries_Worked_QSL'] =  $row->Countries_Worked_QSL; | ||||||
|  |                         $CountriesBreakdown['Countries_Worked_EQSL'] =  $row->Countries_Worked_EQSL; | ||||||
|  |                         $CountriesBreakdown['Countries_Worked_LOTW'] =  $row->Countries_Worked_LOTW; | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 return $CountriesBreakdown; | ||||||
|  |             } | ||||||
|  |             else | ||||||
|  |             { | ||||||
|  |                 return false; | ||||||
|  |             } | ||||||
|  |           } else { | ||||||
|  |             return false; | ||||||
|  |           } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|     /* Return total number of countries confirmed with paper QSL */ |     /* Return total number of countries confirmed with paper QSL */ | ||||||
|     function total_countries_confirmed_paper() { |     function total_countries_confirmed_paper() { | ||||||
|       $CI =& get_instance(); |       $CI =& get_instance(); | ||||||
|  |  | ||||||
		正在加载…
	
		在新工单中引用