Optimized Reihungstest-chronjob code

. Optimized code by retreiving data directly via model.
. Extended SQL query: study courses are now checked for active = true
This commit is contained in:
Cris
2018-12-06 12:37:22 +01:00
parent 1f6f56f71c
commit 38b195beeb
3 changed files with 17 additions and 30 deletions
@@ -40,8 +40,8 @@ class ReihungstestJob extends FHC_Controller
$this->VILESCI_RT_VERWALTUNGS_URL = site_url(). "/organisation/Reihungstest";
// Load libraries
$this->load->library('ReihungstestLib');
// Load models
$this->load->model('crm/Reihungstest_model', 'ReihungstestModel');
// Load helpers
$this->load->helper('hlp_sancho_helper');
@@ -63,7 +63,7 @@ class ReihungstestJob extends FHC_Controller
public function runReihungstestJob()
{
// Get study plans that have no assigned placement tests yet
$result = $this->reihungstestlib->checkMissingReihungstest();
$result = $this->ReihungstestModel->checkMissingReihungstest();
$missing_rt_arr = array();
if (hasData($result))
@@ -76,7 +76,7 @@ class ReihungstestJob extends FHC_Controller
}
// Get free places
$result = $this->reihungstestlib->getFreePlaces();
$result = $this->ReihungstestModel->getFreePlaces();
$free_places_arr = array();
if (hasData($result))
@@ -108,7 +108,7 @@ class ReihungstestJob extends FHC_Controller
* Returns associative array with data as needed in the reihungstest job template.
* @param array $missing_rt_arr Array with studienpläne, which have no assigned placement tests.
* @param array $free_places_arr Array with info and amount of free placement test places.
* @return array
* @return array
*/
private function _getContentData($missing_rt_arr, $free_places_arr)
{
-23
View File
@@ -81,27 +81,4 @@ class ReihungstestLib
return false;
}
/**
* Checks if there are active studyplans which have no public placement tests assigned yet.
* Only check studyplans that are
* - bachelor,
* - active,
* - set as online application
* - valid for 1st term
* @return type
*/
public function checkMissingReihungstest()
{
return $this->ci->ReihungstestModel->checkMissingReihungstest();
}
/** Gets amount of free places.
* Retrieves faculty and amount of free places for each public placement test date.
* @return array
*/
public function getFreePlaces()
{
return $this->ci->ReihungstestModel->getFreePlaces();
}
}
+12 -2
View File
@@ -41,6 +41,12 @@ class Reihungstest_model extends DB_Model
/**
* Checks if there are active studyplans which have no public placement tests assigned yet.
* Only check assignment to studyplans that are
* - Bachelor,
* - active,
* - set as online application
* - valid for 1st terms
* @return array Returns object array with studyplans that have no public placement tests assigned yet.
*/
public function checkMissingReihungstest()
{
@@ -70,6 +76,8 @@ class Reihungstest_model extends DB_Model
public.tbl_studiengang
USING (studiengang_kz)
WHERE
tbl_studiengang.aktiv = \'t\'
AND
tbl_studiensemester.onlinebewerbung = \'t\'
AND
tbl_studienplan.onlinebewerbung_studienplan = \'t\'
@@ -97,8 +105,10 @@ class Reihungstest_model extends DB_Model
return $this->execQuery($query);
}
/** Gets amount of free places.
* Retrieves faculty and amount of free places for each public placement test date.
/**
* Gets amount of free places.
* @return array Returns object array with faculty and amount of free places
* for each public actual placement test date.
*/
public function getFreePlaces()
{