Browse Source

feat(taskprocessing): rename cleanup column to allow_cleanup

Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
pull/54272/head
Julien Veyssier 3 months ago
parent
commit
222b19b805
No known key found for this signature in database GPG Key ID: 4141FEE162030638
  1. 6
      core/Migrations/Version32000Date20250806110519.php
  2. 2
      core/ResponseDefinitions.php
  3. 4
      core/openapi-ex_app.json
  4. 4
      core/openapi-full.json
  5. 4
      core/openapi.json
  6. 16
      lib/private/TaskProcessing/Db/Task.php
  7. 8
      lib/private/TaskProcessing/Db/TaskMapper.php
  8. 16
      lib/public/TaskProcessing/Task.php
  9. 4
      openapi.json

6
core/Migrations/Version32000Date20250806110519.php

@ -19,7 +19,7 @@ use OCP\Migration\SimpleMigrationStep;
/**
*
*/
#[AddColumn(table: 'taskprocessing_tasks', name: 'cleanup', type: ColumnType::SMALLINT)]
#[AddColumn(table: 'taskprocessing_tasks', name: 'allow_cleanup', type: ColumnType::SMALLINT)]
class Version32000Date20250806110519 extends SimpleMigrationStep {
/**
@ -34,8 +34,8 @@ class Version32000Date20250806110519 extends SimpleMigrationStep {
if ($schema->hasTable('taskprocessing_tasks')) {
$table = $schema->getTable('taskprocessing_tasks');
if (!$table->hasColumn('cleanup')) {
$table->addColumn('cleanup', Types::SMALLINT, [
if (!$table->hasColumn('allow_cleanup')) {
$table->addColumn('allow_cleanup', Types::SMALLINT, [
'notnull' => true,
'default' => 1,
'unsigned' => true,

2
core/ResponseDefinitions.php

@ -200,7 +200,7 @@ namespace OC\Core;
* scheduledAt: ?int,
* startedAt: ?int,
* endedAt: ?int,
* cleanup: bool,
* allowCleanup: bool,
* }
*
* @psalm-type CoreProfileAction = array{

4
core/openapi-ex_app.json

@ -146,7 +146,7 @@
"scheduledAt",
"startedAt",
"endedAt",
"cleanup"
"allowCleanup"
],
"properties": {
"id": {
@ -218,7 +218,7 @@
"format": "int64",
"nullable": true
},
"cleanup": {
"allowCleanup": {
"type": "boolean"
}
}

4
core/openapi-full.json

@ -640,7 +640,7 @@
"scheduledAt",
"startedAt",
"endedAt",
"cleanup"
"allowCleanup"
],
"properties": {
"id": {
@ -712,7 +712,7 @@
"format": "int64",
"nullable": true
},
"cleanup": {
"allowCleanup": {
"type": "boolean"
}
}

4
core/openapi.json

@ -640,7 +640,7 @@
"scheduledAt",
"startedAt",
"endedAt",
"cleanup"
"allowCleanup"
],
"properties": {
"id": {
@ -712,7 +712,7 @@
"format": "int64",
"nullable": true
},
"cleanup": {
"allowCleanup": {
"type": "boolean"
}
}

16
lib/private/TaskProcessing/Db/Task.php

@ -45,8 +45,8 @@ use OCP\TaskProcessing\Task as OCPTask;
* @method int getStartedAt()
* @method setEndedAt(int $endedAt)
* @method int getEndedAt()
* @method setCleanup(int $cleanup)
* @method int getCleanup()
* @method setAllowCleanup(int $allowCleanup)
* @method int getAllowCleanup()
*/
class Task extends Entity {
protected $lastUpdated;
@ -65,17 +65,17 @@ class Task extends Entity {
protected $scheduledAt;
protected $startedAt;
protected $endedAt;
protected $cleanup;
protected $allowCleanup;
/**
* @var string[]
*/
public static array $columns = ['id', 'last_updated', 'type', 'input', 'output', 'status', 'user_id', 'app_id', 'custom_id', 'completion_expected_at', 'error_message', 'progress', 'webhook_uri', 'webhook_method', 'scheduled_at', 'started_at', 'ended_at', 'cleanup'];
public static array $columns = ['id', 'last_updated', 'type', 'input', 'output', 'status', 'user_id', 'app_id', 'custom_id', 'completion_expected_at', 'error_message', 'progress', 'webhook_uri', 'webhook_method', 'scheduled_at', 'started_at', 'ended_at', 'allow_cleanup'];
/**
* @var string[]
*/
public static array $fields = ['id', 'lastUpdated', 'type', 'input', 'output', 'status', 'userId', 'appId', 'customId', 'completionExpectedAt', 'errorMessage', 'progress', 'webhookUri', 'webhookMethod', 'scheduledAt', 'startedAt', 'endedAt', 'cleanup'];
public static array $fields = ['id', 'lastUpdated', 'type', 'input', 'output', 'status', 'userId', 'appId', 'customId', 'completionExpectedAt', 'errorMessage', 'progress', 'webhookUri', 'webhookMethod', 'scheduledAt', 'startedAt', 'endedAt', 'allowCleanup'];
public function __construct() {
@ -97,7 +97,7 @@ class Task extends Entity {
$this->addType('scheduledAt', 'integer');
$this->addType('startedAt', 'integer');
$this->addType('endedAt', 'integer');
$this->addType('cleanup', 'integer');
$this->addType('allowCleanup', 'integer');
}
public function toRow(): array {
@ -126,7 +126,7 @@ class Task extends Entity {
'scheduledAt' => $task->getScheduledAt(),
'startedAt' => $task->getStartedAt(),
'endedAt' => $task->getEndedAt(),
'cleanup' => $task->getCleanup(),
'allowCleanup' => $task->getAllowCleanup(),
]);
return $taskEntity;
}
@ -149,7 +149,7 @@ class Task extends Entity {
$task->setScheduledAt($this->getScheduledAt());
$task->setStartedAt($this->getStartedAt());
$task->setEndedAt($this->getEndedAt());
$task->setCleanup($this->getCleanup() !== 0);
$task->setAllowCleanup($this->getAllowCleanup() !== 0);
return $task;
}
}

8
lib/private/TaskProcessing/Db/TaskMapper.php

@ -183,7 +183,7 @@ class TaskMapper extends QBMapper {
/**
* @param int $timeout
* @param bool $force If true, ignore the cleanup flag
* @param bool $force If true, ignore the allow_cleanup flag
* @return int the number of deleted tasks
* @throws Exception
*/
@ -192,14 +192,14 @@ class TaskMapper extends QBMapper {
$qb->delete($this->tableName)
->where($qb->expr()->lt('last_updated', $qb->createPositionalParameter($this->timeFactory->getDateTime()->getTimestamp() - $timeout)));
if (!$force) {
$qb->andWhere($qb->expr()->eq('cleanup', $qb->createPositionalParameter(1, IQueryBuilder::PARAM_INT)));
$qb->andWhere($qb->expr()->eq('allow_cleanup', $qb->createPositionalParameter(1, IQueryBuilder::PARAM_INT)));
}
return $qb->executeStatement();
}
/**
* @param int $timeout
* @param bool $force If true, ignore the cleanup flag
* @param bool $force If true, ignore the allow_cleanup flag
* @return \Generator<Task>
* @throws Exception
*/
@ -209,7 +209,7 @@ class TaskMapper extends QBMapper {
->from($this->tableName)
->where($qb->expr()->lt('last_updated', $qb->createPositionalParameter($this->timeFactory->getDateTime()->getTimestamp() - $timeout)));
if (!$force) {
$qb->andWhere($qb->expr()->eq('cleanup', $qb->createPositionalParameter(1, IQueryBuilder::PARAM_INT)));
$qb->andWhere($qb->expr()->eq('allow_cleanup', $qb->createPositionalParameter(1, IQueryBuilder::PARAM_INT)));
}
foreach ($this->yieldEntities($qb) as $entity) {
yield $entity;

16
lib/public/TaskProcessing/Task.php

@ -66,7 +66,7 @@ final class Task implements \JsonSerializable {
protected ?int $scheduledAt = null;
protected ?int $startedAt = null;
protected ?int $endedAt = null;
protected bool $cleanup = true;
protected bool $allowCleanup = true;
/**
* @param string $taskTypeId
@ -257,20 +257,20 @@ final class Task implements \JsonSerializable {
* @return bool
* @since 32.0.0
*/
final public function getCleanup(): bool {
return $this->cleanup;
final public function getAllowCleanup(): bool {
return $this->allowCleanup;
}
/**
* @param bool $cleanup
* @param bool $allowCleanup
* @since 32.0.0
*/
final public function setCleanup(bool $cleanup): void {
$this->cleanup = $cleanup;
final public function setAllowCleanup(bool $allowCleanup): void {
$this->allowCleanup = $allowCleanup;
}
/**
* @psalm-return array{id: int, lastUpdated: int, type: string, status: 'STATUS_CANCELLED'|'STATUS_FAILED'|'STATUS_SUCCESSFUL'|'STATUS_RUNNING'|'STATUS_SCHEDULED'|'STATUS_UNKNOWN', userId: ?string, appId: string, input: array<string, list<numeric|string>|numeric|string>, output: ?array<string, list<numeric|string>|numeric|string>, customId: ?string, completionExpectedAt: ?int, progress: ?float, scheduledAt: ?int, startedAt: ?int, endedAt: ?int, cleanup: bool}
* @psalm-return array{id: int, lastUpdated: int, type: string, status: 'STATUS_CANCELLED'|'STATUS_FAILED'|'STATUS_SUCCESSFUL'|'STATUS_RUNNING'|'STATUS_SCHEDULED'|'STATUS_UNKNOWN', userId: ?string, appId: string, input: array<string, list<numeric|string>|numeric|string>, output: ?array<string, list<numeric|string>|numeric|string>, customId: ?string, completionExpectedAt: ?int, progress: ?float, scheduledAt: ?int, startedAt: ?int, endedAt: ?int, allowCleanup: bool}
* @since 30.0.0
*/
final public function jsonSerialize(): array {
@ -289,7 +289,7 @@ final class Task implements \JsonSerializable {
'scheduledAt' => $this->getScheduledAt(),
'startedAt' => $this->getStartedAt(),
'endedAt' => $this->getEndedAt(),
'cleanup' => $this->getCleanup(),
'allowCleanup' => $this->getAllowCleanup(),
];
}

4
openapi.json

@ -678,7 +678,7 @@
"scheduledAt",
"startedAt",
"endedAt",
"cleanup"
"allowCleanup"
],
"properties": {
"id": {
@ -750,7 +750,7 @@
"format": "int64",
"nullable": true
},
"cleanup": {
"allowCleanup": {
"type": "boolean"
}
}

Loading…
Cancel
Save