Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/deck.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaul <raul@nextcloud.com>2022-05-03 13:59:58 +0300
committerJulius Härtl <jus@bitgrid.net>2022-11-11 17:47:06 +0300
commit0a30b73f103da0685ffea17b63a4fdbf2bd96aed (patch)
treef1e2214c12e411b7b0edc822d55913c91168d3aa
parent159e37ee6036cf66aa544580ae454afb14b5fbf9 (diff)
Update Card serialization (`jsonSerialize` usages) to use CardDetails model
Signed-off-by: Raul <raul@nextcloud.com>
-rw-r--r--lib/Service/OverviewService.php31
1 files changed, 22 insertions, 9 deletions
diff --git a/lib/Service/OverviewService.php b/lib/Service/OverviewService.php
index 0d883141..f45f22f3 100644
--- a/lib/Service/OverviewService.php
+++ b/lib/Service/OverviewService.php
@@ -93,7 +93,7 @@ class OverviewService {
public function findUpcomingCards(string $userId): array {
$userBoards = $this->boardMapper->findAllForUser($userId);
- $foundCards = [];
+ $overview = [];
foreach ($userBoards as $userBoard) {
if (count($userBoard->getAcl()) === 0) {
// private board: get cards with due date
@@ -103,14 +103,27 @@ class OverviewService {
$cards = $this->cardMapper->findToMeOrNotAssignedCards($userBoard->getId(), $userId);
}
- $foundCards[] = array_map(
- function (Card $card) use ($userBoard, $userId) {
- $this->enrich($card, $userId);
- return (new CardDetails($card, $userBoard))->jsonSerialize();
- },
- $cards
- );
+ foreach ($cards as $card) {
+ $this->enrich($card, $userId);
+ $diffDays = $card->getDaysUntilDue();
+
+ $key = 'later';
+ if ($card->getDuedate() === 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, $userBoard));
+ $overview[$key][] = $card->jsonSerialize();
+ }
}
- return array_merge(...$foundCards);
+ return $overview;
}
}