Add Functionality Frontend: triggering of reloading tags for prestudent from studentHeader

Refactoring: Recycling of tags instead of deleting it and creating new ones
This commit is contained in:
ma0068
2026-04-08 14:26:14 +02:00
parent 50af6694d0
commit e9e614aa52
7 changed files with 336 additions and 174 deletions
@@ -45,4 +45,5 @@ class Tags extends Tag_Controller
{
parent::doneTag($this->config->item('stv_prestudent_tags'));
}
}
+29 -160
View File
@@ -8,7 +8,7 @@ class TagJob extends JOB_Controller
{
const BATCHUSER = 'sftest';
const SEMESTER = 'SS2024'; //docker
const SEMESTER = 'WS2025'; //docker
//TODO semester
/**
@@ -37,70 +37,15 @@ class TagJob extends JOB_Controller
]);
}
/**
* Test createTags
*/
public function createAutomatedTagsForPrestudents(...$prestudentIds)
public function rebuildAutomatedTags()
{
print_r( PHP_EOL . "Start Job create Automated Tags" . PHP_EOL);
$tag_typ_kurzbz = "wh_auto";
$notiz = "TEST AUTOMATED TAG";
$zuordnung_typ = "prestudent_id";
$count = 0;
$values = ($prestudentIds != null) ? $prestudentIds : [ 125239, 167955];
$checkZuordnungType = $this->NotizzuordnungModel->isValidType($zuordnung_typ);
if (!isSuccess($checkZuordnungType))
return error('Error occurred');
$values = array_unique($values);
foreach ($values as $value)
{
//TODO(uid)
$resultInsertNotiz = $this->NotizModel->insert(array(
'titel' => 'TAG',
'text' => $notiz,
'verfasser_uid' => self::BATCHUSER,
'erledigt' => false,
'insertamum' => date('Y-m-d H:i:s'),
'insertvon' => self::BATCHUSER,
'typ' => $tag_typ_kurzbz
));
if (isError($resultInsertNotiz))
return error ('Error occurred insert Result ' . $value);
$resultInsertZuordnung = $this->NotizzuordnungModel->insert(array(
'notiz_id' => $resultInsertNotiz->retval,
$zuordnung_typ => $value
));
print_r( PHP_EOL . "Tag vom Typ " . $tag_typ_kurzbz . " für " . $zuordnung_typ . " " . $value . " erstellt");
if (isError($resultInsertZuordnung))
return error ('Error occurred insert Zuordnung' . $value);
$count++;
}
print_r( PHP_EOL . "Automatically created Tags: " . $count . PHP_EOL);
print_r( PHP_EOL . "End Job create Automated Tags" . PHP_EOL);
}
public function createAutomatedTags()
{
print_r( PHP_EOL . "Start Job create Automated Tags: " . PHP_EOL);
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))
{
print_r(PHP_EOL . "create Tags wiederholer " . PHP_EOL);
$result = $this->PrestudentstatusModel-> loadWhere(array(
'statusgrund_id' => 16,
'studiensemester_kurzbz' => self::SEMESTER
@@ -110,127 +55,51 @@ class TagJob extends JOB_Controller
return $item->prestudent_id;
}, $data);
$result = $this->taglib->getAutomatedTags('wh_auto', $ids);
if (isError($result))
return error ('Error occurred getAutomatedTags');
$result = $this->taglib->updateAutomatedTags('wh_auto', $ids);
$data = $result->retval;
if (isError($result))
return error ('Error occurred during updateAutomatedTags');
print_r( PHP_EOL . "Automatically created Tags of Type WIEDERHOLER: " . $data[0] . PHP_EOL);
print_r( "prestudents: " . implode( ", ", $data[1]) . PHP_EOL);
print_r(PHP_EOL ."ALL TAGS 'wh_auto' " . 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);
}
if(in_array('prewh_auto', $automaticTags))
{
print_r(PHP_EOL . "create Tags pre-wiederholer " . PHP_EOL);
$result = $this->PrestudentstatusModel-> loadWhere(array(
$result = $this->PrestudentstatusModel->loadWhere(array(
'statusgrund_id' => 15,
'studiensemester_kurzbz' => self::SEMESTER
));
$data = $result->retval;
$ids = array_map(function($item) {
$ids = array_map(function ($item) {
return $item->prestudent_id;
}, $data);
$result = $this->taglib->getAutomatedTags('prewh_auto', $ids);
$result = $this->taglib->updateAutomatedTags('prewh_auto', $ids);
if (isError($result))
return error ('Error occurred getAutomatedTags');
return error('Error occurred during updateAutomatedTags');
$data = $result->retval;
print_r( PHP_EOL . "Automatically created Tags of Type PRE-WIEDERHOLER: " . $data[0] . PHP_EOL);
print_r( "prestudents: " . implode( ", ", $data[1]) . PHP_EOL);
print_r(PHP_EOL . "ALL TAGS 'prewh_auto' " . 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);
}
if(in_array('dd_auto', $automaticTags))
{
print_r(PHP_EOL . "create Tags double degree" . PHP_EOL);
print_r( PHP_EOL . "End Job rebuild" . PHP_EOL);
print_r( PHP_EOL . "Automatically created Tags of Type DOUBLE DEGREE: " . $data[0] . PHP_EOL);
print_r( "prestudents: " . implode( ", ", $data[1]) . PHP_EOL);
}
/* $tag_typ_kurzbz = "wh_auto";
$notiz = "TEST AUTOMATED TAG";
$zuordnung_typ = "prestudent_id";
$count = 0;
$values = ($arrayToTag != null) ? $arrayToTag : [ 125239, 167955];
$checkZuordnungType = $this->NotizzuordnungModel->isValidType($zuordnung_typ);
if (!isSuccess($checkZuordnungType))
return error('Error occurred');
$values = array_unique($values);
foreach ($values as $value)
{
//TODO(uid)
$resultInsertNotiz = $this->NotizModel->insert(array(
'titel' => 'TAG',
'text' => $notiz,
'verfasser_uid' => self::BATCHUSER,
'erledigt' => false,
'insertamum' => date('Y-m-d H:i:s'),
'insertvon' => self::BATCHUSER,
'typ' => $tag_typ_kurzbz
));
if (isError($resultInsertNotiz))
return error ('Error occurred insert Result ' . $value);
$resultInsertZuordnung = $this->NotizzuordnungModel->insert(array(
'notiz_id' => $resultInsertNotiz->retval,
$zuordnung_typ => $value
));
print_r( PHP_EOL . "Tag vom Typ " . $tag_typ_kurzbz . " für " . $zuordnung_typ . " " . $value . " erstellt");
if (isError($resultInsertZuordnung))
return error ('Error occurred insert Zuordnung' . $value);
$count++;
}
print_r( PHP_EOL . "Automatically created Tags: " . $count . PHP_EOL);*/
print_r( PHP_EOL . "End Job create Automated Tags" . PHP_EOL);
}
/**
* delete All Automatic Tags
*/
public function deleteAutomatedTags()
{
print_r( PHP_EOL . "Start Job delete ALL Automated Tags" . PHP_EOL);
// $this->NotizModel->select('notiz_id');
$resultToDelete = $this->NotizModel->loadWhere(array('insertvon' => self::BATCHUSER));
$data = $resultToDelete->retval;
$notiz_ids = array_map(function($item) {
return $item->notiz_id;
}, $data);
print_r($notiz_ids);
foreach ($notiz_ids as $notiz_id)
{
$result = $this->NotizzuordnungModel->delete([
'notiz_id' => $notiz_id
]);
if (isError($result))
return error ('Error occurred delete Notizzuordnung' . $notiz_id);
$result = $this->NotizModel->delete([
'notiz_id' => $notiz_id
]);
if (isError($result))
return error ('Error occurred delete Notiz' . $notiz_id);
}
print_r( PHP_EOL . "End Job delete Automated Tags" . PHP_EOL);
}
}