fix logic and tests, update docker CI file
This commit is contained in:
@@ -65,13 +65,13 @@ class IncidentAnalysisService
|
||||
}
|
||||
|
||||
if ($students[$studentKey]['last_incident'] === null) {
|
||||
$students[$studentKey]['last_incident'] = $incident['incident_datetime'] ?? null;
|
||||
$students[$studentKey]['last_incident'] = $this->formatIncidentDate($incident['incident_datetime'] ?? null);
|
||||
}
|
||||
|
||||
$students[$studentKey]['logs'][] = [
|
||||
'incident' => $incident['incident'] ?? '',
|
||||
'incident_state' => $state,
|
||||
'incident_datetime' => $incident['incident_datetime'] ?? null,
|
||||
'incident_datetime' => $this->formatIncidentDate($incident['incident_datetime'] ?? null),
|
||||
'open_description' => $incident['open_description'] ?? null,
|
||||
'close_description' => $incident['close_description'] ?? null,
|
||||
'cancel_description' => $incident['cancel_description'] ?? null,
|
||||
@@ -89,4 +89,23 @@ class IncidentAnalysisService
|
||||
|
||||
return $studentRows;
|
||||
}
|
||||
|
||||
private function formatIncidentDate(mixed $value): ?string
|
||||
{
|
||||
if ($value === null || $value === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($value instanceof \DateTimeInterface) {
|
||||
return $value->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
$raw = (string) $value;
|
||||
$ts = strtotime($raw);
|
||||
if ($ts !== false) {
|
||||
return date('Y-m-d H:i:s', $ts);
|
||||
}
|
||||
|
||||
return $raw;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user