kopia lustrzana https://github.com/magicbug/Cloudlog
[Awards CQ] Added index for speedup. Removed some unused code and reduced number of queries by a few.
rodzic
51ff9c1734
commit
5979cceb33
|
@ -21,7 +21,7 @@ $config['migration_enabled'] = TRUE;
|
||||||
| be upgraded / downgraded to.
|
| be upgraded / downgraded to.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
$config['migration_version'] = 66;
|
$config['migration_version'] = 67;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
@ -213,14 +213,13 @@ class Awards extends CI_Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function cq(){
|
public function cq(){
|
||||||
$this->load->model('cq');
|
$CI =& get_instance();
|
||||||
$zones = array();
|
$CI->load->model('Stations');
|
||||||
foreach($this->cq->get_zones() as $row){
|
$station_id = $CI->Stations->find_active();
|
||||||
array_push($zones, intval($row->COL_CQZ));
|
|
||||||
}
|
|
||||||
$data['cqz'] = $zones;
|
|
||||||
|
|
||||||
$data['worked_bands'] = $this->cq->get_worked_bands();
|
$this->load->model('cq');
|
||||||
|
|
||||||
|
$data['worked_bands'] = $this->cq->get_worked_bands($station_id);
|
||||||
|
|
||||||
if ($this->input->post('band') != NULL) { // Band is not set when page first loads.
|
if ($this->input->post('band') != NULL) { // Band is not set when page first loads.
|
||||||
if ($this->input->post('band') == 'All') { // Did the user specify a band? If not, use all bands
|
if ($this->input->post('band') == 'All') { // Did the user specify a band? If not, use all bands
|
||||||
|
@ -253,8 +252,8 @@ class Awards extends CI_Controller {
|
||||||
$postdata['band'] = 'All';
|
$postdata['band'] = 'All';
|
||||||
}
|
}
|
||||||
|
|
||||||
$data['cq_array'] = $this->cq->get_cq_array($bands, $postdata);
|
$data['cq_array'] = $this->cq->get_cq_array($bands, $postdata, $station_id);
|
||||||
$data['cq_summary'] = $this->cq->get_cq_summary($bands);
|
$data['cq_summary'] = $this->cq->get_cq_summary($data['worked_bands'], $station_id);
|
||||||
|
|
||||||
// Render page
|
// Render page
|
||||||
$data['page_title'] = "Awards - CQ Magazine";
|
$data['page_title'] = "Awards - CQ Magazine";
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This migration creates a table called options which will hold global options needed within cloudlog
|
||||||
|
* removing the need for lots of configuration files.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class Migration_add_index_cqz_prop extends CI_Migration {
|
||||||
|
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
$sql = "ALTER TABLE ".$this->config->item('table_name')." ADD INDEX `HRD_IDX_COL_CQZ` (`COL_CQZ`);";
|
||||||
|
$this->db->query($sql);
|
||||||
|
$sql = "ALTER TABLE ".$this->config->item('table_name')." ADD INDEX `HRD_IDX_COL_PROP_MODE` (`COL_PROP_MODE`);";
|
||||||
|
$this->db->query($sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,7 +15,7 @@ class CQ extends CI_Model{
|
||||||
$data = $this->db->query(
|
$data = $this->db->query(
|
||||||
"select COL_CQZ, count(COL_CQZ)
|
"select COL_CQZ, count(COL_CQZ)
|
||||||
from ".$this->config->item('table_name')."
|
from ".$this->config->item('table_name')."
|
||||||
where COL_CQZ is not null and station_id = ".$station_id."
|
where COL_CQZ is not null and station_id = ".$station_id."
|
||||||
group by COL_CQZ order by COL_CQZ"
|
group by COL_CQZ order by COL_CQZ"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -45,12 +45,8 @@ class CQ extends CI_Model{
|
||||||
"SAT" => 0,
|
"SAT" => 0,
|
||||||
);
|
);
|
||||||
|
|
||||||
function get_worked_bands()
|
function get_worked_bands($station_id)
|
||||||
{
|
{
|
||||||
$CI =& get_instance();
|
|
||||||
$CI->load->model('Stations');
|
|
||||||
$station_id = $CI->Stations->find_active();
|
|
||||||
|
|
||||||
// get all worked slots from database
|
// get all worked slots from database
|
||||||
$data = $this->db->query(
|
$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 = " . $station_id . " AND COL_PROP_MODE != \"SAT\""
|
||||||
|
@ -78,11 +74,7 @@ class CQ extends CI_Model{
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_cq_array($bands, $postdata) {
|
function get_cq_array($bands, $postdata, $station_id) {
|
||||||
$CI =& get_instance();
|
|
||||||
$CI->load->model('Stations');
|
|
||||||
$station_id = $CI->Stations->find_active();
|
|
||||||
|
|
||||||
$cqZ = array(); // Used for keeping track of which states that are not worked
|
$cqZ = array(); // Used for keeping track of which states that are not worked
|
||||||
|
|
||||||
for ($i = 1; $i <= 40; $i++) {
|
for ($i = 1; $i <= 40; $i++) {
|
||||||
|
@ -146,7 +138,7 @@ class CQ extends CI_Model{
|
||||||
* $postdata contains data from the form, in this case Lotw or QSL are used
|
* $postdata contains data from the form, in this case Lotw or QSL are used
|
||||||
*/
|
*/
|
||||||
function getCQWorked($station_id, $band, $postdata) {
|
function getCQWorked($station_id, $band, $postdata) {
|
||||||
$sql = "SELECT distinct col_cqz FROM " . $this->config->item('table_name') . " thcv
|
$sql = "SELECT distinct col_cqz FROM " . $this->config->item('table_name') . " thcv
|
||||||
where station_id = " . $station_id . " and col_cqz <> ''";
|
where station_id = " . $station_id . " and col_cqz <> ''";
|
||||||
|
|
||||||
$sql .= $this->addBandToQuery($band);
|
$sql .= $this->addBandToQuery($band);
|
||||||
|
@ -171,7 +163,7 @@ class CQ extends CI_Model{
|
||||||
* $postdata contains data from the form, in this case Lotw or QSL are used
|
* $postdata contains data from the form, in this case Lotw or QSL are used
|
||||||
*/
|
*/
|
||||||
function getCQConfirmed($station_id, $band, $postdata) {
|
function getCQConfirmed($station_id, $band, $postdata) {
|
||||||
$sql = "SELECT distinct col_cqz FROM " . $this->config->item('table_name') . " thcv
|
$sql = "SELECT distinct col_cqz FROM " . $this->config->item('table_name') . " thcv
|
||||||
where station_id = " . $station_id . " and col_cqz <> ''";
|
where station_id = " . $station_id . " and col_cqz <> ''";
|
||||||
|
|
||||||
$sql .= $this->addBandToQuery($band);
|
$sql .= $this->addBandToQuery($band);
|
||||||
|
@ -215,11 +207,7 @@ class CQ extends CI_Model{
|
||||||
/*
|
/*
|
||||||
* Function gets worked and confirmed summary on each band on the active stationprofile
|
* Function gets worked and confirmed summary on each band on the active stationprofile
|
||||||
*/
|
*/
|
||||||
function get_cq_summary($bands) {
|
function get_cq_summary($bands, $station_id) {
|
||||||
$CI =& get_instance();
|
|
||||||
$CI->load->model('Stations');
|
|
||||||
$station_id = $CI->Stations->find_active();
|
|
||||||
|
|
||||||
foreach ($bands as $band) {
|
foreach ($bands as $band) {
|
||||||
$worked = $this->getSummaryByBand($band, $station_id);
|
$worked = $this->getSummaryByBand($band, $station_id);
|
||||||
$confirmed = $this->getSummaryByBandConfirmed($band, $station_id);
|
$confirmed = $this->getSummaryByBandConfirmed($band, $station_id);
|
||||||
|
|
|
@ -134,8 +134,8 @@
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label class="col-md-2 control-label" for="button1id"></label>
|
<label class="col-md-2 control-label" for="button1id"></label>
|
||||||
<div class="col-md-10">
|
<div class="col-md-10">
|
||||||
<button id="button2id" type="reset" name="button2id" class="btn btn-warning">Reset</button>
|
<button id="button2id" type="reset" name="button2id" class="btn-sm btn-warning">Reset</button>
|
||||||
<button id="button1id" type="submit" name="button1id" class="btn btn-primary">Show</button>
|
<button id="button1id" type="submit" name="button1id" class="btn-sm btn-primary">Show</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@
|
||||||
<thead>
|
<thead>
|
||||||
<tr><td></td>';
|
<tr><td></td>';
|
||||||
|
|
||||||
foreach($bands as $band) {
|
foreach($worked_bands as $band) {
|
||||||
echo '<td>' . $band . '</td>';
|
echo '<td>' . $band . '</td>';
|
||||||
}
|
}
|
||||||
echo '<td>Total</td></tr>
|
echo '<td>Total</td></tr>
|
||||||
|
|
Ładowanie…
Reference in New Issue