Add support for time-based departmental progress tracking

- Introduced calculation of departmental progress for today, week, and month in `department_goals_o.php`.
- Removed unnecessary blank line in `object_property.php` for code clarity.
This commit is contained in:
Jeppe Bundgaard
2026-02-25 14:20:25 +01:00
parent 11a677416b
commit cc494583e0
2 changed files with 5 additions and 1 deletions
@@ -181,7 +181,6 @@ class object_property
$db;
$sql = "UPDATE $this->table SET $this->column = NULL WHERE id = $this->id";
$db->query($sql);
if (defined('redis')) {
redis->delete($this->getCacheKey());
}
@@ -87,6 +87,11 @@ class department_goals_o extends db
'progress' => [
'value' => $include_progress ? goals_criteria::calculateProgressFromArray((array)$this->criteria->value()) : null,
'departmental_distribution' => $include_progress ? goals_criteria::calculateDepartmentalProgressFromArray((array)$this->criteria->value()) : null,
// array of department_id => [ 'all' => [ 'count' => int, 'target' => int ], 'today' => [ 'count' => int, 'target' => int ], 'week' => [ 'count' => int, 'target' => int ], 'month' => [ 'count' => int, 'target' => int ] ]
// Showing progress for different time periods
'today' => $include_progress ? goals_criteria::calculateProgressFromArray((array)$this->criteria->value(), 'today') : null,
'week' => $include_progress ? goals_criteria::calculateProgressFromArray((array)$this->criteria->value(), 'week') : null,
'month' => $include_progress ? goals_criteria::calculateProgressFromArray((array)$this->criteria->value(), 'month') : null,
],
'created_at' => (string)$this->created_at->value(),
'updated_at' => (string)$this->updated_at->value(),