show overdue assignments today
This commit is contained in:
parent
7bc7ad207b
commit
93d2f4ebd6
7 changed files with 77 additions and 13 deletions
|
|
@ -78,7 +78,7 @@ class FakeScheduleRepository implements ScheduleRepository
|
|||
}, array_values($schedules));
|
||||
}
|
||||
|
||||
public function findAssignmentsForUserOnDate(
|
||||
public function findIncompleteAssignmentsForUserDueOnOrBefore(
|
||||
User $user,
|
||||
DateTimeImmutable $date,
|
||||
): array {
|
||||
|
|
@ -86,8 +86,7 @@ class FakeScheduleRepository implements ScheduleRepository
|
|||
|
||||
foreach ($this->findAllForUser($user) as $schedule) {
|
||||
foreach ($schedule->getAssignments() as $assignment) {
|
||||
if ($assignment->getScheduledDate()->format('Y-m-d')
|
||||
!== $date->format('Y-m-d')
|
||||
if ($assignment->getScheduledDate() > $date
|
||||
|| $assignment->getCompletedAt() !== null
|
||||
) {
|
||||
continue;
|
||||
|
|
@ -101,6 +100,37 @@ class FakeScheduleRepository implements ScheduleRepository
|
|||
}
|
||||
}
|
||||
|
||||
usort(
|
||||
$assignments,
|
||||
function (
|
||||
AssignmentForDate $first,
|
||||
AssignmentForDate $second,
|
||||
): int {
|
||||
$firstAssignment = $first->getAssignment();
|
||||
$secondAssignment = $second->getAssignment();
|
||||
$dateComparison = $firstAssignment->getScheduledDate()
|
||||
<=> $secondAssignment->getScheduledDate();
|
||||
if ($dateComparison !== 0) {
|
||||
return $dateComparison;
|
||||
}
|
||||
|
||||
$scheduleComparison = $second->getScheduleId()
|
||||
<=> $first->getScheduleId();
|
||||
if ($scheduleComparison !== 0) {
|
||||
return $scheduleComparison;
|
||||
}
|
||||
|
||||
$positionComparison = $firstAssignment->getPosition()
|
||||
<=> $secondAssignment->getPosition();
|
||||
if ($positionComparison !== 0) {
|
||||
return $positionComparison;
|
||||
}
|
||||
|
||||
return $firstAssignment->getId()
|
||||
<=> $secondAssignment->getId();
|
||||
},
|
||||
);
|
||||
|
||||
return $assignments;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue