fix logic and tests, update docker CI file

This commit is contained in:
root
2026-03-09 15:58:44 -04:00
parent 1cb3573d4b
commit 79e44fe037
188 changed files with 1776 additions and 524 deletions
@@ -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;
}
}
@@ -69,16 +69,20 @@ class IncidentLookupService
}
$rows = DB::table('users')
->select('id, firstname, lastname')
->select('id', 'firstname', 'lastname')
->whereIn('id', $userIds)
->get()
->map(fn ($row) => (array) $row)
->map(fn ($row) => $row instanceof \Illuminate\Contracts\Support\Arrayable ? $row->toArray() : (array) $row)
->all();
$map = [];
foreach ($rows as $row) {
$id = $row['id'] ?? $row['user_id'] ?? null;
if ($id === null) {
continue;
}
$name = trim((string) ($row['firstname'] ?? '') . ' ' . (string) ($row['lastname'] ?? ''));
$map[(int) $row['id']] = $name !== '' ? $name : ('User #' . $row['id']);
$map[(int) $id] = $name !== '' ? $name : ('User #' . $id);
}
return $map;