boardMapper->findAllForUser($userId); $boardOwnerIds = array_filter(array_map(function (Board $board) { return count($board->getAcl() ?? []) === 0 ? $board->getId() : null; }, $userBoards)); $boardSharedIds = array_filter(array_map(function (Board $board) { return count($board->getAcl() ?? []) > 0 ? $board->getId() : null; }, $userBoards)); $foundCards = array_merge( // private board: get cards with due date $this->cardMapper->findAllWithDue($boardOwnerIds), // shared board: get all my assigned or unassigned cards $this->cardMapper->findToMeOrNotAssignedCards($boardSharedIds, $userId) ); $this->cardService->enrichCards($foundCards); $overview = []; foreach ($foundCards as $card) { $diffDays = $card->getDaysUntilDue(); $key = 'later'; if ($diffDays === null) { $key = 'nodue'; } elseif ($diffDays < 0) { $key = 'overdue'; } elseif ($diffDays === 0) { $key = 'today'; } elseif ($diffDays === 1) { $key = 'tomorrow'; } elseif ($diffDays <= 7) { $key = 'nextSevenDays'; } $card = (new CardDetails($card, $card->getRelatedBoard())); $overview[$key][] = $card->jsonSerialize(); } return $overview; } }