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
@@ -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,
};
}
}