Add lastModified field to labels
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -41,6 +41,7 @@ class LabelTest extends TestCase {
|
||||
'title' => 'My Label',
|
||||
'boardId' => 123,
|
||||
'cardId' => null,
|
||||
'lastModified' => null,
|
||||
'color' => '000000'
|
||||
], $label->jsonSerialize());
|
||||
|
||||
@@ -53,6 +54,7 @@ class LabelTest extends TestCase {
|
||||
'title' => 'My Label',
|
||||
'boardId' => null,
|
||||
'cardId' => 123,
|
||||
'lastModified' => null,
|
||||
'color' => '000000'
|
||||
], $label->jsonSerialize());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user