enh(Text2Image): Expose expected completion time

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
pull/40326/head
Marcel Klehr 3 years ago
parent 4c58edc1b7
commit 9ee72633cf
  1. 3
      core/Migrations/Version28000Date20230906104802.php
  2. 3
      core/ResponseDefinitions.php
  3. 7
      core/openapi.json
  4. 10
      lib/private/TextToImage/Db/Task.php
  5. 22
      lib/public/TextToImage/Task.php

@ -82,6 +82,9 @@ class Version28000Date20230906104802 extends SimpleMigrationStep {
$table->addColumn('last_updated', Types::DATETIME, [
'notnull' => false,
]);
$table->addColumn('completion_expeted_at', Types::DATETIME, [
'notnull' => false,
]);
$table->setPrimaryKey(['id'], 't2i_tasks_id_index');
$table->addIndex(['last_updated'], 't2i_tasks_updated');

@ -152,7 +152,8 @@ namespace OCA\Core;
* appId: string,
* input: string,
* identifier: ?string,
* numberOfImages: int
* numberOfImages: int,
* completionExpectedAt: int,
* }
*/
class ResponseDefinitions {

@ -459,7 +459,8 @@
"appId",
"input",
"identifier",
"numberOfImages"
"numberOfImages",
"completionExpectedAt"
],
"properties": {
"id": {
@ -488,6 +489,10 @@
"numberOfImages": {
"type": "integer",
"format": "int64"
},
"completionExpectedAt": {
"type": "integer",
"format": "int64"
}
}
},

@ -46,6 +46,8 @@ use OCP\TextToImage\Task as OCPTask;
* @method string|null getIdentifier()
* @method setNumberOfImages(int $numberOfImages)
* @method int getNumberOfImages()
* @method setCompletionExpectedAt(DateTime $at)
* @method DateTime getCompletionExpectedAt()
*/
class Task extends Entity {
protected $lastUpdated;
@ -56,16 +58,17 @@ class Task extends Entity {
protected $appId;
protected $identifier;
protected $numberOfImages;
protected $completionExpectedAt;
/**
* @var string[]
*/
public static array $columns = ['id', 'last_updated', 'input', 'status', 'user_id', 'app_id', 'identifier', 'number_of_images'];
public static array $columns = ['id', 'last_updated', 'input', 'status', 'user_id', 'app_id', 'identifier', 'number_of_images', 'completion_expected_at'];
/**
* @var string[]
*/
public static array $fields = ['id', 'lastUpdated', 'input', 'status', 'userId', 'appId', 'identifier', 'numberOfImages'];
public static array $fields = ['id', 'lastUpdated', 'input', 'status', 'userId', 'appId', 'identifier', 'numberOfImages', 'completionExpectedAt'];
public function __construct() {
@ -78,6 +81,7 @@ class Task extends Entity {
$this->addType('appId', 'string');
$this->addType('identifier', 'string');
$this->addType('numberOfImages', 'integer');
$this->addType('completionExpectedAt', 'datetime');
}
public function toRow(): array {
@ -97,6 +101,7 @@ class Task extends Entity {
'userId' => $task->getUserId(),
'appId' => $task->getAppId(),
'identifier' => $task->getIdentifier(),
'completionExpectedAt' => $task->getCompletionExpectedAt(),
]);
return $dbTask;
}
@ -105,6 +110,7 @@ class Task extends Entity {
$task = new OCPTask($this->getInput(), $this->getAppId(), $this->getNumberOfImages(), $this->getuserId(), $this->getIdentifier());
$task->setId($this->getId());
$task->setStatus($this->getStatus());
$task->setCompletionExpectedAt($this->getCompletionExpectedAt());
return $task;
}
}

@ -25,6 +25,7 @@ declare(strict_types=1);
namespace OCP\TextToImage;
use DateTime;
use OCP\Files\AppData\IAppDataFactory;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
@ -39,6 +40,8 @@ use OCP\Image;
final class Task implements \JsonSerializable {
protected ?int $id = null;
protected DateTime $completionExpectedAt;
/**
* @since 28.0.0
*/
@ -124,6 +127,22 @@ final class Task implements \JsonSerializable {
$this->status = $status;
}
/**
* @param DateTime $at
* @since 28.0.0
*/
final public function setCompletionExpectedAt(DateTime $at): void {
$this->completionExpectedAt = $at;
}
/**
* @return DateTime
* @since 28.0.0
*/
final public function getCompletionExpectedAt(): DateTime {
return $this->completionExpectedAt;
}
/**
* @return int|null
* @since 28.0.0
@ -173,7 +192,7 @@ final class Task implements \JsonSerializable {
}
/**
* @psalm-return array{id: ?int, status: 0|1|2|3|4, userId: ?string, appId: string, input: string, identifier: ?string, numberOfImages: int}
* @psalm-return array{id: ?int, status: 0|1|2|3|4, userId: ?string, appId: string, input: string, identifier: ?string, numberOfImages: int, completionExpectedAt: int}
* @since 28.0.0
*/
public function jsonSerialize(): array {
@ -185,6 +204,7 @@ final class Task implements \JsonSerializable {
'numberOfImages' => $this->getNumberOfImages(),
'input' => $this->getInput(),
'identifier' => $this->getIdentifier(),
'completionExpectedAt' => $this->getCompletionExpectedAt()->getTimestamp(),
];
}
}

Loading…
Cancel
Save