Issues: Behebung parameter are included in identification of an issue

This commit is contained in:
KarpAlex
2023-07-11 15:58:48 +02:00
parent f4c8f00c8f
commit 1416e91af7
2 changed files with 35 additions and 16 deletions
+21 -15
View File
@@ -246,7 +246,27 @@ class IssuesLib
$fehlertext = vsprintf($fehlertextVorlage, $fehlertext_params);
}
$openIssuesCountRes = $this->_ci->IssueModel->getOpenIssueCount($fehlercode, $person_id, $oe_kurzbz, $fehlercode_extern);
if (isset($resolution_params))
{
if (is_array($resolution_params))
{
foreach ($resolution_params as $resolution_key => $resolution_param)
{
if (!is_string($resolution_key))
return error("Invalid parameter for resolution, must be an associative array");
}
}
else
return error("Invalid parameters for resolution");
}
$openIssuesCountRes = $this->_ci->IssueModel->getOpenIssueCount(
$fehlercode,
$person_id,
$oe_kurzbz,
$fehlercode_extern,
$resolution_params
);
if (hasData($openIssuesCountRes))
{
@@ -256,20 +276,6 @@ class IssuesLib
if ($openIssueCount == 0)
{
if (isset($resolution_params))
{
if (is_array($resolution_params))
{
foreach ($resolution_params as $resolution_key => $resolution_param)
{
if (!is_string($resolution_key))
return error("Invalid parameter for resolution, must be an associative array");
}
}
else
return error("Invalid parameters for resolution");
}
// insert new issue
return $this->_ci->IssueModel->insert(
array(
+14 -1
View File
@@ -59,7 +59,7 @@ class Issue_model extends DB_Model
* @param string $fehlercode_extern if provided, only issues with this external fehlercode are counted (for identifying issues from external systems).
* @return Object success with number of issues or error
*/
public function getOpenIssueCount($fehlercode, $person_id = null, $oe_kurzbz = null, $fehlercode_extern = null)
public function getOpenIssueCount($fehlercode, $person_id = null, $oe_kurzbz = null, $fehlercode_extern = null, $behebung_parameter = null)
{
$params = array($fehlercode);
// issue exists for a fehlercode (or fehlercode_extern), person_id, oe_kurzbz, if not verarbeitet yet
@@ -85,6 +85,19 @@ class Issue_model extends DB_Model
$params[] = $oe_kurzbz;
}
if (isset($behebung_parameter) && !isEmptyArray($behebung_parameter))
{
// convert array to JSON string for postgres
$behebung_parameter_string = json_encode($behebung_parameter);
if ($behebung_parameter_string)
{
// check if jsonb value is equal to the passed parameters array (if value contains array and array contains value)
$qry .= ' AND behebung_parameter @> ? AND behebung_parameter <@ ?';
$params = array_merge($params, array($behebung_parameter_string, $behebung_parameter_string));
}
}
return $this->execQuery($qry, $params);
}
}