added reverted attribute to DiffTaskResult

This commit is contained in:
Jonathan Treffler 2024-01-24 20:22:02 +01:00 committed by root
parent 4870225d66
commit 5b6470a53b
3 changed files with 14 additions and 1 deletions

View file

@ -18,6 +18,7 @@ class DiffTaskResult extends Entity implements JsonSerializable {
protected $currentFileExists; protected $currentFileExists;
protected $currentPath; protected $currentPath;
protected $currentSize; protected $currentSize;
protected $reverted;
public function __construct() { public function __construct() {
$this->addType('id','integer'); $this->addType('id','integer');
@ -26,6 +27,7 @@ class DiffTaskResult extends Entity implements JsonSerializable {
$this->addType('beforeSize','integer'); $this->addType('beforeSize','integer');
$this->addType('currentFileExists','boolean'); $this->addType('currentFileExists','boolean');
$this->addType('currentSize','integer'); $this->addType('currentSize','integer');
$this->addType('reverted','boolean');
} }
public function jsonSerialize() { public function jsonSerialize() {
@ -42,7 +44,8 @@ class DiffTaskResult extends Entity implements JsonSerializable {
'fileExists' => $this->currentFileExists, 'fileExists' => $this->currentFileExists,
'path' => $this->currentPath, 'path' => $this->currentPath,
'size' => $this->currentSize, 'size' => $this->currentSize,
] ],
'reverted' => $this->reverted,
]; ];
} }
} }

View file

@ -33,4 +33,10 @@ class DiffTaskResultMapper extends QBMapper {
return $this->findEntities($qb); return $this->findEntities($qb);
} }
public function markReverted(int $id) {
$taskResult = $this->find($id);
$taskResult->setReverted(True);
return $this->update($taskResult);
}
} }

View file

@ -94,6 +94,10 @@
'default' => 0 'default' => 0
]); ]);
$table->addColumn('reverted', 'boolean', [
'default' => false,
]);
$table->setPrimaryKey(['id']); $table->setPrimaryKey(['id']);
$table->addIndex(['task_id'], 'taskid_index'); $table->addIndex(['task_id'], 'taskid_index');
$table->addForeignKeyConstraint($schema->getTable(self::TASKS_TABLE), ['task_id'], ['id'], ['onDelete' => 'CASCADE'], 'results_taskid_fk'); $table->addForeignKeyConstraint($schema->getTable(self::TASKS_TABLE), ['task_id'], ['id'], ['onDelete' => 'CASCADE'], 'results_taskid_fk');