Add progress calculation and enhance department goal management
- Introduce progress-related functionality in `goals_criteria` and enumeration for alert frequencies. - Add `calculateProgressFromArray` for progress evaluation based on criteria arrays. - Extend `department_goals_o` with `name` property and optional inclusion of progress in goal exports. - Update OpenAPI spec with endpoints and schemas for department goal management.
This commit is contained in:
@@ -132,6 +132,15 @@ class goals_criteria implements goals_criteria_i
|
||||
return $criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function calculateProgressFromArray(array $criteria_array): float
|
||||
{
|
||||
$criteria = self::fromJson(json_encode($criteria_array));
|
||||
return $criteria->getProgress();
|
||||
}
|
||||
|
||||
/**
|
||||
* Export the criteria as an associative array suitable for JSON encoding.
|
||||
* Ensures a canonical schema matching fromJson expectations.
|
||||
@@ -168,4 +177,12 @@ class goals_criteria implements goals_criteria_i
|
||||
{
|
||||
return json_encode($this->toArray());
|
||||
}
|
||||
|
||||
private function getProgress(): int
|
||||
{
|
||||
return match ($this->type) {
|
||||
goals_criteria_type::PRODUCT => $this->products->count($this),
|
||||
default => 0,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user