Pipeline and codestyle fixes

Signed-off-by: Raul <raul@nextcloud.com>
This commit is contained in:
Raul
2022-05-05 13:50:16 +02:00
parent 9369a697e3
commit 9fca104059
5 changed files with 35 additions and 27 deletions

View File

@@ -23,6 +23,14 @@
namespace OCA\Deck\Db;
/**
* @method int getId()
* @method string getTitle()
* @method int getShared()
* @method bool getArchived()
* @method int getDeletedAt()
* @method int getLastModified()
*/
class Board extends RelationalEntity {
protected $title;
protected $owner;

View File

@@ -92,7 +92,7 @@ class Card extends RelationalEntity {
protected $relatedStack = null;
protected $relatedBoard = null;
protected $databaseType = 'sqlite';
private $databaseType = 'sqlite';
public const DUEDATE_FUTURE = 0;
public const DUEDATE_NEXT = 1;
@@ -108,6 +108,7 @@ class Card extends RelationalEntity {
$this->addType('archived', 'boolean');
$this->addType('notified', 'boolean');
$this->addType('deletedAt', 'integer');
$this->addType('duedate', 'string');
$this->addRelation('labels');
$this->addRelation('assignedUsers');
$this->addRelation('attachments');

View File

@@ -24,11 +24,10 @@ 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 = null) {
public function __construct(Board $board) {
parent::__construct();
$this->board = $board;
}
@@ -40,7 +39,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);
}
}

View File

@@ -26,8 +26,7 @@ use DateTime;
use OCA\Deck\Db\Board;
use OCA\Deck\Db\Card;
class CardDetails extends Card
{
class CardDetails extends Card {
private Card $card;
private ?Board $board;
@@ -42,14 +41,10 @@ class CardDetails extends Card
}
public function jsonSerialize(array $extras = []): array {
$array = parent::jsonSerialize();
$array = $this->card->jsonSerialize();
unset($array['notified'], $array['descriptionPrev'], $array['relatedStack'], $array['relatedBoard']);
$array['overdue'] = $this->getDueStatus();
unset($array['notified']);
unset($array['descriptionPrev']);
unset($array['relatedStack']);
unset($array['relatedBoard']);
$this->appendBoardDetails($array);
return $array;
@@ -59,23 +54,27 @@ class CardDetails extends Card
$today = new DateTime();
$today->setTime(0, 0);
$match_date = $this->getDueDateTime() ?? new DateTime();
$match_date = $this->card->getDueDateTime();
if (!$match_date) {
return Card::DUEDATE_FUTURE;
}
$match_date->setTime(0, 0);
$diff = $today->diff($match_date);
$diffDays = (integer) $diff->format('%R%a'); // Extract days count in interval
$diffDays = (int) $diff->format('%R%a'); // Extract days count in interval
if ($diffDays === 1) {
return static::DUEDATE_NEXT;
return Card::DUEDATE_NEXT;
}
if ($diffDays === 0) {
return static::DUEDATE_NOW;
return Card::DUEDATE_NOW;
}
if ($diffDays < 0) {
return static::DUEDATE_OVERDUE;
return Card::DUEDATE_OVERDUE;
}
return static::DUEDATE_FUTURE;
return Card::DUEDATE_FUTURE;
}
private function appendBoardDetails(&$array): void {
@@ -87,7 +86,7 @@ class CardDetails extends Card
$array['board'] = (new BoardSummary($this->board))->jsonSerialize();
}
protected function getter($name) {
return $this->card->getter($name);
public function __call($name, $arguments) {
return $this->card->__call($name, $arguments);
}
}

View File

@@ -25,6 +25,7 @@ namespace OCA\Deck\Db;
use DateInterval;
use DateTime;
use OCA\Deck\Model\CardDetails;
use Test\TestCase;
class CardTest extends TestCase {
@@ -59,7 +60,7 @@ class CardTest extends TestCase {
public function testDuedate(DateTime $duedate, $state) {
$card = $this->createCard();
$card->setDuedate($duedate->format('Y-m-d H:i:s'));
$this->assertEquals($state, $card->jsonSerialize()['overdue']);
$this->assertEquals($state, (new CardDetails($card))->jsonSerialize()['overdue']);
}
public function testJsonSerialize() {
@@ -86,7 +87,7 @@ class CardTest extends TestCase {
'commentsCount' => 0,
'lastEditor' => null,
'ETag' => $card->getETag(),
], $card->jsonSerialize());
], (new CardDetails($card))->jsonSerialize());
}
public function testJsonSerializeLabels() {
$card = $this->createCard();
@@ -113,7 +114,7 @@ class CardTest extends TestCase {
'commentsCount' => 0,
'lastEditor' => null,
'ETag' => $card->getETag(),
], $card->jsonSerialize());
], (new CardDetails($card))->jsonSerialize());
}
public function testMysqlDateFallback() {
@@ -150,6 +151,6 @@ class CardTest extends TestCase {
'commentsCount' => 0,
'lastEditor' => null,
'ETag' => $card->getETag(),
], $card->jsonSerialize());
], (new CardDetails($card))->jsonSerialize());
}
}