From dd7e025220b70f8856807c307d9b4f25005cd180 Mon Sep 17 00:00:00 2001 From: Cris Date: Thu, 6 Dec 2018 12:37:22 +0100 Subject: [PATCH] Optimized Reihungstest-chronjob code . Optimized code by retreiving data directly via model. . Extended SQL query: study plans are now checked for active = true --- .../controllers/jobs/ReihungstestJob.php | 10 ++++---- application/libraries/ReihungstestLib.php | 23 ------------------- application/models/crm/Reihungstest_model.php | 14 +++++++++-- 3 files changed, 17 insertions(+), 30 deletions(-) diff --git a/application/controllers/jobs/ReihungstestJob.php b/application/controllers/jobs/ReihungstestJob.php index 8f1ade01f..e58595bb0 100644 --- a/application/controllers/jobs/ReihungstestJob.php +++ b/application/controllers/jobs/ReihungstestJob.php @@ -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) { diff --git a/application/libraries/ReihungstestLib.php b/application/libraries/ReihungstestLib.php index b90d9e6fc..5b40e65e3 100644 --- a/application/libraries/ReihungstestLib.php +++ b/application/libraries/ReihungstestLib.php @@ -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(); - } } diff --git a/application/models/crm/Reihungstest_model.php b/application/models/crm/Reihungstest_model.php index 09f01fe5f..9614c2e38 100644 --- a/application/models/crm/Reihungstest_model.php +++ b/application/models/crm/Reihungstest_model.php @@ -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() {