summaryrefslogtreecommitdiffstats
path: root/lib/private/LanguageModel/Db/Task.php
blob: 895969e08bb91bac6c4622437733248d0c6d0336 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php

namespace OC\LanguageModel\Db;

use OCP\AppFramework\Db\Entity;
use OCP\LanguageModel\ILanguageModelTask;

/**
 * @method setType(string $type)
 * @method string getType()
 * @method setLastUpdated(int $lastUpdated)
 * @method int getLastUpdated()
 * @method setInput(string $type)
 * @method string getInput()
 * @method setStatus(int $type)
 * @method int getStatus()
 * @method setUserId(string $type)
 * @method string getuserId()
 * @method setAppId(string $type)
 * @method string getAppId()
 */
class Task extends Entity {
	protected $lastUpdated;

	protected $type;
	protected $input;
	protected $status;
	protected $userId;
	protected $appId;

	/**
	 * @var string[]
	 */
	public static array $columns = ['id', 'last_updated', 'type', 'input', 'output', 'status', 'user_id', 'app_id'];

	/**
	 * @var string[]
	 */
	public static array $fields = ['id', 'lastUpdated', 'type', 'input', 'output', 'status', 'userId', 'appId'];


	public function __construct() {
		// add types in constructor
		$this->addType('id', 'integer');
		$this->addType('lastUpdated', 'integer');
		$this->addType('type', 'string');
		$this->addType('input', 'string');
		$this->addType('status', 'integer');
		$this->addType('userId', 'string');
		$this->addType('appId', 'string');
	}

	public static function fromLanguageModelTask(ILanguageModelTask $task): Task {
		return Task::fromParams([
			'type' => $task->getType(),
			'lastUpdated' => time(),
			'status' => $task->getStatus(),
			'input' => $task->getInput(),
			'output' => $task->getOutput(),
			'userId' => $task->getUserId(),
			'appId' => $task->getAppId(),
		]);
	}
}