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:
Jeppe Bundgaard
2026-01-26 18:51:31 +01:00
parent b4b72d7537
commit c1b7f5bad6
4 changed files with 306 additions and 59 deletions
@@ -13,6 +13,7 @@ class department_goals_o extends db
{
use db_object_t;
public object_property $created_by; // The user_id who created the goal
public object_property $name; // The name of the goal
public object_property $departments; // A JSON with the department ids
public object_property $criteria; // A JSON with the criteria object
public object_property $created_at;
@@ -64,13 +65,19 @@ class department_goals_o extends db
//TODO: Add cache invalidation
}
public function asArray(): array
/**
* @throws Exception
*/
public function asArray($include_progress = true): array
{
return [
'id' => (int)$this->id,
'created_by' => (int)$this->created_by->value(),
'departments' => (array)$this->departments->value(),
'criteria' => (array)$this->criteria->value(),
'progress' => [
'value' => $include_progress ? goals_criteria::calculateProgressFromArray((array)$this->criteria->value()) : null,
],
'created_at' => (string)$this->created_at->value(),
'updated_at' => (string)$this->updated_at->value(),
];