* Refactor this function.

This commit is contained in:
dingguodong
2023-08-24 14:10:59 +08:00
parent 5bd32fde0b
commit 378c337900
+8 -2
View File
@@ -254,6 +254,7 @@ class taskModel extends model
}
/**
* 从GitLab议题创建任务。
* Create task from gitlab issue.
*
* @param object $task
@@ -261,21 +262,26 @@ class taskModel extends model
* @access public
* @return int
*/
public function createTaskFromGitlabIssue($task, $executionID)
public function createTaskFromGitlabIssue(object $task, int $executionID): int|false
{
$task->version = 1;
$task->openedBy = $this->app->user->account;
$task->lastEditedBy = $this->app->user->account;
$task->assignedDate = isset($task->assignedTo) ? helper::now() : 0;
$task->assignedDate = isset($task->assignedTo) ? helper::now() : null;
$task->story = 0;
$task->module = 0;
$task->estimate = 0;
$task->deadline = $task->deadline ?? null;
$task->estStarted = null;
$task->left = 0;
$task->pri = 3;
$task->type = 'devel';
$task->execution = $task->execution ?? $executionID;
$task->project = $this->dao->select('project')->from(TABLE_PROJECT)->where('id')->eq($executionID)->fetch('project');
/* Set project of the task to 0 if the project of execution is not exist. */
if(empty($task->project)) $task->project = 0;
$this->dao->insert(TABLE_TASK)->data($task, 'id,product')
->autoCheck()
->batchCheck($this->config->task->create->requiredFields, 'notempty')