Added migration to set the station_id to indexed also created a second station model that returns qso count so that sped things up

pull/355/head
Peter Goodhall 2019-09-25 00:38:13 +01:00
rodzic fdb19f6406
commit 76e24b545d
4 zmienionych plików z 25 dodań i 3 usunięć

Wyświetl plik

@ -21,7 +21,7 @@ $config['migration_enabled'] = TRUE;
| be upgraded / downgraded to.
|
*/
$config['migration_version'] = 32;
$config['migration_version'] = 33;
/*
|--------------------------------------------------------------------------

Wyświetl plik

@ -20,7 +20,7 @@ class Station extends CI_Controller {
$this->load->model('stations');
$this->load->model('Logbook_model');
$data['stations'] = $this->stations->all();
$data['stations'] = $this->stations->all_with_count();
$data['current_active'] = $this->stations->find_active();
$data['is_there_qsos_with_no_station_id'] = $this->Logbook_model->check_for_station_id();

Wyświetl plik

@ -0,0 +1,18 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Migration_log_setindex_station_id extends CI_Migration {
public function up()
{
$this->db->db_debug = false;
$this->db->query("ALTER TABLE ".$this->config->item('table_name')." ADD INDEX(`station_id`);");
$this->db->db_debug = true;
}
public function down()
{
echo "Not possible, sorry.";
}
}

Wyświetl plik

@ -8,7 +8,7 @@ class Stations extends CI_Model {
parent::__construct();
}
function all() {
function all_with_count() {
$this->db->select('station_profile.*, count('.$this->config->item('table_name').'.station_id) as qso_total');
$this->db->from('station_profile');
@ -17,6 +17,10 @@ class Stations extends CI_Model {
return $this->db->get();
}
function all() {
return $this->db->get('station_profile');
}
function profile($id) {
$this->db->where('station_id', $id);
return $this->db->get('station_profile');