mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-16 22:42:16 +00:00
Refactor TagJob and TabLib: use dynamic approach with column taglib for creating Tags
This commit is contained in:
@@ -8,7 +8,7 @@ class TagJob extends JOB_Controller
|
||||
{
|
||||
|
||||
const BATCHUSER = 'sftest';
|
||||
const SEMESTER = 'WS2025'; //docker
|
||||
const SEMESTER = 'SS2026'; //docker
|
||||
//TODO semester
|
||||
|
||||
/**
|
||||
@@ -49,7 +49,40 @@ class TagJob extends JOB_Controller
|
||||
$taglib = strtolower(basename($autoTag->taglib));
|
||||
$this->load->library($autoTag->taglib);
|
||||
|
||||
$ids = $this->$taglib->getZuordnungIds(array('studiensemester_kurzbz' => 'SS2026'));
|
||||
$ids = $this->$taglib->getZuordnungIds(array('studiensemester_kurzbz' => self::SEMESTER));
|
||||
print_r($ids);
|
||||
}
|
||||
}
|
||||
|
||||
public function loadTagLibs()
|
||||
{
|
||||
$automatedTagsRes = $this->NotiztypModel->loadWhere(array('automatisiert' => true, 'taglib IS NOT NULL' => null));
|
||||
//echo $this->NotiztypModel->db->last_query();
|
||||
$automatedTags = hasData($automatedTagsRes) ? getData($automatedTagsRes) : [];
|
||||
print_r($automatedTags);
|
||||
|
||||
foreach($automatedTags as $autoTag)
|
||||
{
|
||||
// getPath: must not be lost
|
||||
$filePath = APPPATH . 'libraries/' . $autoTag->taglib . '.php'; // APPPATH = application/
|
||||
|
||||
if(file_exists($filePath)) {
|
||||
require_once($filePath);
|
||||
} else {
|
||||
echo "File not found: " . $filePath;
|
||||
continue;
|
||||
}
|
||||
|
||||
// className without PATH (basename)
|
||||
$className = basename($autoTag->taglib);
|
||||
|
||||
$obj = new $className();
|
||||
$ids = $obj->getZuordnungIds(['studiensemester_kurzbz' => self::SEMESTER]);
|
||||
|
||||
$kurz_bz = $autoTag->typ_kurzbz;
|
||||
|
||||
echo PHP_EOL . $className . ": ";
|
||||
echo PHP_EOL . $kurz_bz . ": ";
|
||||
print_r($ids);
|
||||
}
|
||||
}
|
||||
@@ -60,6 +93,59 @@ class TagJob extends JOB_Controller
|
||||
$automaticTags = $this->config->item('stv_automatic_tags');
|
||||
print_r( implode( ", ", $automaticTags) . PHP_EOL);
|
||||
|
||||
$automatedTagsRes = $this->NotiztypModel->loadWhere(array('automatisiert' => true, 'taglib IS NOT NULL' => null));
|
||||
//echo $this->NotiztypModel->db->last_query();
|
||||
$automatedTags = hasData($automatedTagsRes) ? getData($automatedTagsRes) : [];
|
||||
print_r($automatedTags);
|
||||
|
||||
|
||||
foreach($automatedTags as $autoTag)
|
||||
{
|
||||
// getPath: must not be lost
|
||||
$filePath = APPPATH . 'libraries/' . $autoTag->taglib . '.php'; // APPPATH = application/
|
||||
|
||||
if(file_exists($filePath)) {
|
||||
require_once($filePath);
|
||||
} else {
|
||||
echo "File not found: " . $filePath . PHP_EOL;
|
||||
continue;
|
||||
}
|
||||
|
||||
$kurz_bz = $autoTag->typ_kurzbz;
|
||||
// className without PATH (basename)
|
||||
$className = basename($autoTag->taglib);
|
||||
|
||||
$obj = new $className();
|
||||
$ids = $obj->getZuordnungIds(['studiensemester_kurzbz' => self::SEMESTER]);
|
||||
|
||||
$idsArray = $ids->prestudent_id;
|
||||
|
||||
$result = $this->taglib->updateAutomatedTags($kurz_bz, $idsArray);
|
||||
$data = $result->retval;
|
||||
if (isError($result))
|
||||
return error ('Error occurred during updateAutomatedTags');
|
||||
|
||||
print_r(PHP_EOL ."ALL TAGS " . $kurz_bz . " " . count($data[0]) . " TO ADD " . count($data[1]) . " TO RECYLE: " . count($data[2]) . " TO DELETE: " . count($data[3]));
|
||||
|
||||
|
||||
print_r( PHP_EOL . "Count Recycled: ");
|
||||
print_r($data[4]);
|
||||
print_r( PHP_EOL . "Count Added: ");
|
||||
print_r($data[6]);
|
||||
print_r( PHP_EOL . "Count Deleted: ");
|
||||
print_r($data[8] . PHP_EOL . PHP_EOL);
|
||||
|
||||
}
|
||||
print_r( PHP_EOL . "End Job rebuild" . PHP_EOL);
|
||||
|
||||
}
|
||||
|
||||
public function rebuildAutomatedTags_DEPR()
|
||||
{
|
||||
print_r( PHP_EOL . "Start Job rebuild" . PHP_EOL);
|
||||
$automaticTags = $this->config->item('stv_automatic_tags');
|
||||
print_r( implode( ", ", $automaticTags) . PHP_EOL);
|
||||
|
||||
//TODO(Manu) use a loop in library?
|
||||
if(in_array('wh_auto', $automaticTags))
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@ class TagLib
|
||||
{
|
||||
const BATCHUSER = 'sftest';
|
||||
const TYP_ZUORDNUNG = 'prestudent_id';
|
||||
const SEMESTER = 'WS2025';
|
||||
const SEMESTER = 'SS2026';
|
||||
|
||||
/**
|
||||
* Object initialization
|
||||
@@ -233,11 +233,67 @@ class TagLib
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* main function for rebuild Tags for single prestudent
|
||||
* manually triggered
|
||||
* */
|
||||
/*
|
||||
* main function for rebuild Tags for single prestudent
|
||||
* manually triggered
|
||||
* */
|
||||
public function rebuildTagsForPrestudent($prestudent_id)
|
||||
{
|
||||
$automatedTagsRes = $this->_ci->NotiztypModel->loadWhere(array('automatisiert' => true, 'taglib IS NOT NULL' => null));
|
||||
//echo $this->NotiztypModel->db->last_query();
|
||||
$automatedTags = hasData($automatedTagsRes) ? getData($automatedTagsRes) : [];
|
||||
print_r($automatedTags);
|
||||
|
||||
$return = [];
|
||||
|
||||
foreach($automatedTags as $autoTag)
|
||||
{
|
||||
// getPath: must not be lost
|
||||
$filePath = APPPATH . 'libraries/' . $autoTag->taglib . '.php'; // APPPATH = application/
|
||||
|
||||
if (file_exists($filePath)) {
|
||||
require_once($filePath);
|
||||
} else {
|
||||
echo "File not found: " . $filePath;
|
||||
continue;
|
||||
}
|
||||
|
||||
// className without PATH (basename)
|
||||
$className = basename($autoTag->taglib);
|
||||
|
||||
$obj = new $className();
|
||||
$criteriaIsSet = $obj->isCriteriaSetFor([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'studiensemester_kurzbz' => self::SEMESTER
|
||||
]);
|
||||
//$return = $this->_ci->PrestudentstatusModel->db->last_query();
|
||||
$kurz_bz = $autoTag->typ_kurzbz;
|
||||
|
||||
// $return[$kurz_bz] = $criteriaIsSet;
|
||||
|
||||
if($criteriaIsSet)
|
||||
{
|
||||
$result = $this->updateAutomatedTagsForPrestudent($kurz_bz, $prestudent_id);
|
||||
if (isError($result))
|
||||
return error ('Error occurred during updateAutomatedTags' . $kurz_bz);
|
||||
|
||||
else
|
||||
$return[$kurz_bz] = $result;
|
||||
}
|
||||
else {
|
||||
$result = $this->checkForDelete($kurz_bz, $prestudent_id);
|
||||
if($result != null)
|
||||
$return[$kurz_bz] = $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return success($return);
|
||||
|
||||
}
|
||||
|
||||
public function rebuildTagsForPrestudentDEPR($prestudent_id)
|
||||
{
|
||||
$automaticTags = $this->_ci->config->item('stv_automatic_tags');
|
||||
$return = [];
|
||||
@@ -259,8 +315,6 @@ class TagLib
|
||||
$return[$tag] = $result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return success($return);
|
||||
|
||||
}
|
||||
@@ -304,7 +358,7 @@ class TagLib
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function isCriteriaSetFor($tag, $prestudent_id)
|
||||
public function isCriteriaSetFor_DEPR($tag, $prestudent_id)
|
||||
{
|
||||
//TODO(finish list)
|
||||
if($tag == 'wh_auto')
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/**
|
||||
* Description of prewh_auto
|
||||
*
|
||||
* @author bambi
|
||||
*/
|
||||
class CorePrewiederholerTagLib
|
||||
{
|
||||
protected $ci;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->ci = get_instance();
|
||||
$this->ci->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel');
|
||||
}
|
||||
|
||||
public function getZuordnungIds(array $params)
|
||||
{
|
||||
if(!isset($params['studiensemester_kurzbz']))
|
||||
{
|
||||
return (object) array(
|
||||
'prestudent_id' => []
|
||||
);
|
||||
}
|
||||
|
||||
$semester = $params['studiensemester_kurzbz'];
|
||||
$result = $this->ci->PrestudentstatusModel-> loadWhere(array(
|
||||
'statusgrund_id' => 15,
|
||||
'studiensemester_kurzbz' => $semester
|
||||
));
|
||||
$data = $result->retval;
|
||||
$ids = array_map(function($item) {
|
||||
return $item->prestudent_id;
|
||||
}, $data);
|
||||
|
||||
return (object) array(
|
||||
'prestudent_id' => $ids
|
||||
);
|
||||
}
|
||||
|
||||
public function isCriteriaSetFor(array $params)
|
||||
{
|
||||
if(!isset($params['prestudent_id']) || !isset($params['studiensemester_kurzbz']))
|
||||
{
|
||||
return (object) array(
|
||||
'isSet' => false
|
||||
);
|
||||
}
|
||||
|
||||
$semester = $params['studiensemester_kurzbz'];
|
||||
$prestudent_id = $params['prestudent_id'];
|
||||
|
||||
$result = $this->ci->PrestudentstatusModel->loadWhere(array(
|
||||
'statusgrund_id' => 15,
|
||||
'studiensemester_kurzbz' => $semester,
|
||||
'prestudent_id' => $prestudent_id
|
||||
));
|
||||
if(hasData($result))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -38,5 +38,28 @@ class CoreWiederholerTagLib
|
||||
);
|
||||
}
|
||||
|
||||
public function isCriteriaSetFor(array $params)
|
||||
{
|
||||
if(!isset($params['prestudent_id']) || !isset($params['studiensemester_kurzbz']))
|
||||
{
|
||||
return (object) array(
|
||||
'isSet' => false
|
||||
);
|
||||
}
|
||||
|
||||
$semester = $params['studiensemester_kurzbz'];
|
||||
$prestudent_id = $params['prestudent_id'];
|
||||
|
||||
$result = $this->ci->PrestudentstatusModel->loadWhere(array(
|
||||
'statusgrund_id' => 16,
|
||||
'studiensemester_kurzbz' => $semester,
|
||||
'prestudent_id' => $prestudent_id
|
||||
));
|
||||
if(hasData($result))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user