Add lastModified field to labels

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2019-04-10 16:39:57 +02:00
parent d9305fc347
commit b0eaae6705
4 changed files with 26 additions and 1 deletions

View File

@@ -317,6 +317,13 @@
<notnull>true</notnull>
<length>8</length>
</field>
<field>
<name>last_modified</name>
<type>integer</type>
<default></default>
<notnull>false</notnull>
<unsigned>true</unsigned>
</field>
<index>
<name>deck_labels_board_id_index</name>
<field>

View File

@@ -29,10 +29,12 @@ class Label extends RelationalEntity {
protected $color;
protected $boardId;
protected $cardId;
protected $lastModified;
public function __construct() {
$this->addType('id', 'integer');
$this->addType('boardId', 'integer');
$this->addType('cardId', 'integer');
$this->addType('lastModified', 'integer');
}
}

View File

@@ -23,6 +23,7 @@
namespace OCA\Deck\Db;
use OCP\AppFramework\Db\Entity;
use OCP\IDBConnection;
@@ -54,6 +55,19 @@ class LabelMapper extends DeckMapper implements IPermissionMapper {
return $this->findEntities($sql, [$boardId], $limit, $offset);
}
public function insert(Entity $entity) {
$entity->setLastModified(time());
return parent::insert($entity);
}
public function update(Entity $entity, $updateModified = true) {
if ($updateModified) {
$entity->setLastModified(time());
}
return parent::update($entity);
}
public function getAssignedLabelsForBoard($boardId) {
$labels = $this->findAssignedLabelsForBoard($boardId);
$result = array();

View File

@@ -41,6 +41,7 @@ class LabelTest extends TestCase {
'title' => 'My Label',
'boardId' => 123,
'cardId' => null,
'lastModified' => null,
'color' => '000000'
], $label->jsonSerialize());
@@ -53,10 +54,11 @@ class LabelTest extends TestCase {
'title' => 'My Label',
'boardId' => null,
'cardId' => 123,
'lastModified' => null,
'color' => '000000'
], $label->jsonSerialize());
}
}
}