diff options
author | Raul <raul@nextcloud.com> | 2022-05-09 15:44:36 +0300 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2022-11-11 17:47:06 +0300 |
commit | 08258b2a4056528de46350931ad69658a8cc294f (patch) | |
tree | b087ec91d3090ce17d75289123afdb2fceff5da5 | |
parent | ea07fc19d34ece06986089136461cdd1ceddbcd7 (diff) |
Fix due status calculationenh/upcomming_card_optimisation
Signed-off-by: Raul <raul@nextcloud.com>
-rw-r--r-- | lib/Db/Card.php | 9 | ||||
-rw-r--r-- | lib/Model/BoardSummary.php | 5 | ||||
-rw-r--r-- | lib/Model/CardDetails.php | 17 | ||||
-rw-r--r-- | lib/Service/OverviewService.php | 2 |
4 files changed, 17 insertions, 16 deletions
diff --git a/lib/Db/Card.php b/lib/Db/Card.php index b866fd3e..5a80ed35 100644 --- a/lib/Db/Card.php +++ b/lib/Db/Card.php @@ -158,11 +158,14 @@ class Card extends RelationalEntity { return $calendar; } - public function getDaysUntilDue(): int { + public function getDaysUntilDue(): ?int { $today = new DateTime(); - $today->setTime(0, 0); + $match_date = $this->getDuedate(); + if ($match_date === null) { + return null; + } - $match_date = $this->getDueDateTime() ?? new DateTime(); + $today->setTime(0, 0); $match_date->setTime(0, 0); $diff = $today->diff($match_date); diff --git a/lib/Model/BoardSummary.php b/lib/Model/BoardSummary.php index 2fa827a3..365a454c 100644 --- a/lib/Model/BoardSummary.php +++ b/lib/Model/BoardSummary.php @@ -24,8 +24,7 @@ namespace OCA\Deck\Model; use OCA\Deck\Db\Board; -class BoardSummary extends Board -{ +class BoardSummary extends Board { private Board $board; public function __construct(Board $board) { @@ -42,7 +41,7 @@ class BoardSummary extends Board protected function getter($name) { return $this->board->getter($name); - } + } public function __call($name, $arguments) { return $this->board->__call($name, $arguments); diff --git a/lib/Model/CardDetails.php b/lib/Model/CardDetails.php index 8f80e586..d894c274 100644 --- a/lib/Model/CardDetails.php +++ b/lib/Model/CardDetails.php @@ -25,8 +25,7 @@ namespace OCA\Deck\Model; use OCA\Deck\Db\Board; use OCA\Deck\Db\Card; -class CardDetails extends Card -{ +class CardDetails extends Card { private Card $card; private ?Board $board; @@ -60,18 +59,18 @@ class CardDetails extends Card private function getDueStatus(): int { $diffDays = $this->getDaysUntilDue(); + if ($diffDays === null || $diffDays > 1) { + return static::DUEDATE_FUTURE; + } if ($diffDays === 1) { return static::DUEDATE_NEXT; } if ($diffDays === 0) { return static::DUEDATE_NOW; } - if ($diffDays < 0) { - return static::DUEDATE_OVERDUE; - } - return static::DUEDATE_FUTURE; - } + return static::DUEDATE_OVERDUE; + } private function appendBoardDetails(&$array): void { if (!$this->board) { @@ -83,8 +82,8 @@ class CardDetails extends Card } protected function getter($name) { - return $this->card->getter($name); - } + return $this->card->getter($name); + } public function __call($name, $arguments) { return $this->card->__call($name, $arguments); } diff --git a/lib/Service/OverviewService.php b/lib/Service/OverviewService.php index f45f22f3..8b8b0751 100644 --- a/lib/Service/OverviewService.php +++ b/lib/Service/OverviewService.php @@ -108,7 +108,7 @@ class OverviewService { $diffDays = $card->getDaysUntilDue(); $key = 'later'; - if ($card->getDuedate() === null) { + if ($diffDays === null) { $key = 'nodue'; } elseif ($diffDays < 0) { $key = 'overdue'; |