Skip to content

Commit

Permalink
added left status into entry list endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Lung committed Jun 1, 2024
1 parent 0ccb193 commit 9c21c34
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/Entry/EntryStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@ enum EntryStatus: string
case ENTRY_STATUS_VALID = 'valid';
case ENTRY_STATUS_USED = 'used';
case ENTRY_STATUS_INVALID = 'invalid';
case ENTRY_STATUS_LEAVED = 'leaved';
case ENTRY_STATUS_LEAVED = 'left';

public static function entryFromDatetime(
?DateTimeInterface $entryDate,
?DateTimeInterface $leaveDate,
): self {
if ($leaveDate !== null) {
return self::ENTRY_STATUS_LEAVED;
}

public static function entryFromDatetime(?DateTimeInterface $entryDate): self
{
return match ($entryDate) {
null => self::ENTRY_STATUS_VALID,
default => self::ENTRY_STATUS_USED,
Expand Down
6 changes: 5 additions & 1 deletion src/Participant/ParticipantRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ private function mapDataToEntryParticipant(Row $row): EntryParticipant
* patrol_leader_id: int|null,
* sfh_done: bool|null,
* entry_date: \DateTimeInterface|null,
* leave_date: \DateTimeInterface|null,
* role: string|null
* } $array */
$array = $row->toArray();
Expand All @@ -443,7 +444,10 @@ private function mapDataToEntryParticipant(Row $row): EntryParticipant
$array['patrol_name'] ?? '',
$array['tie_code'],
$array['birth_date'] ?? DateTimeUtils::getDateTime(),
EntryStatus::entryFromDatetime($array['entry_date']),
EntryStatus::entryFromDatetime(
$array['entry_date'],
$array['leave_date'],
),
$array['sfh_done'] ?? false,
);
}
Expand Down

0 comments on commit 9c21c34

Please sign in to comment.