* Bug fix and optimize for import issue.
This commit is contained in:
+9
-10
@@ -283,18 +283,16 @@ class bugModel extends model
|
||||
*/
|
||||
public function createBugFromGitlabIssue($bug, $executionID)
|
||||
{
|
||||
$bug->openedBy = $this->app->user->account;
|
||||
$bug->openedBuild = 0;
|
||||
$bug->story = 0;
|
||||
$bug->task = 0;
|
||||
$bug->project = $this->dao->select('parent')->from(TABLE_EXECUTION)->where('id')->eq($executionID)->fetch('parent');
|
||||
$bug->openedBy = $this->app->user->account;
|
||||
$bug->openedDate = helper::now(); // TODO(dingguodong) use from issue->created_at ?
|
||||
$bug->assignedDate = isset($bug->assignedTo) ? helper::now() : 0;
|
||||
$bug->openedBuild = 1;
|
||||
$bug->story = 0;
|
||||
$bug->task = 0;
|
||||
$bug->project = $this->dao->select('parent')->from(TABLE_EXECUTION)->where('id')->eq($executionID)->fetch('parent');
|
||||
|
||||
$this->dao->insert(TABLE_BUG)->data($bug, $skip = 'gitlab,gitlabProject')->autoCheck()->batchCheck($this->config->bug->create->requiredFields, 'notempty')->exec();
|
||||
if(!dao::isError())
|
||||
{
|
||||
$bugID = $this->dao->lastInsertID();
|
||||
return $bugID;
|
||||
}
|
||||
if(!dao::isError()) return $this->dao->lastInsertID();
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -675,6 +673,7 @@ class bugModel extends model
|
||||
if(!empty($bug))
|
||||
{
|
||||
$relation = $this->loadModel('gitlab')->getRelationByObject('bug', $bugID);
|
||||
$bug->id = $bugID;
|
||||
if($relation) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug);
|
||||
}
|
||||
return common::createChanges($oldBug, $bug);
|
||||
|
||||
@@ -285,21 +285,11 @@ class gitlab extends control
|
||||
$object = $this->gitlab->issueToZentaoObject($issue, $gitlabID);
|
||||
$object->product = $productList[$issueID];
|
||||
$object->execution = $executionID;
|
||||
$clonedObject = clone $object;
|
||||
|
||||
if($objectType == 'task')
|
||||
{
|
||||
$objectID = $this->loadModel('task')->createTaskFromGitlabIssue($object, $executionID);
|
||||
}
|
||||
|
||||
if($objectType == 'bug')
|
||||
{
|
||||
$objectID = $this->loadModel('bug')->createBugFromGitlabIssue($object, $executionID);
|
||||
}
|
||||
|
||||
if($objectType == 'story')
|
||||
{
|
||||
$objectID = $this->loadModel('story')->createStoryFromGitlabIssue($object, $executionID);
|
||||
}
|
||||
if($objectType == 'task') $objectID = $this->loadModel('task')->createTaskFromGitlabIssue($clonedObject, $executionID);
|
||||
if($objectType == 'bug') $objectID = $this->loadModel('bug')->createBugFromGitlabIssue($clonedObject, $executionID);
|
||||
if($objectType == 'story') $objectID = $this->loadModel('story')->createStoryFromGitlabIssue($clonedObject, $executionID);
|
||||
|
||||
if($objectID)
|
||||
{
|
||||
|
||||
@@ -1159,6 +1159,8 @@ class gitlabModel extends model
|
||||
if($optionType == 'userPairs' and isset($issue->$gitlabField)) $value = zget($gitlabUsers, $issue->$gitlabField);
|
||||
if($optionType == 'configItems' and isset($issue->$gitlabField)) $value = array_search($issue->$gitlabField, $this->config->gitlab->$options);
|
||||
if($value) $object->$zentaoField = $value;
|
||||
|
||||
if($gitlabField == "description") $object->$zentaoField .= "<br>" . $issue->web_url;
|
||||
}
|
||||
return $object;
|
||||
}
|
||||
|
||||
@@ -358,10 +358,11 @@ class storyModel extends model
|
||||
*/
|
||||
public function createStoryFromGitlabIssue($story, $executionID)
|
||||
{
|
||||
$story->status = 'active';
|
||||
$story->stage = 'projected';
|
||||
$story->openedBy = 'openedBy';
|
||||
$story->version = '1';
|
||||
$story->status = 'active';
|
||||
$story->stage = 'projected';
|
||||
$story->openedBy = $this->app->user->account;
|
||||
$story->version = 1;
|
||||
$story->assignedDate = isset($story->assignedTo) ? helper::now() : 0;
|
||||
|
||||
if(isset($story->execution)) unset($story->execution);
|
||||
|
||||
|
||||
+12
-12
@@ -464,25 +464,25 @@ class taskModel extends model
|
||||
*/
|
||||
public function createTaskFromGitlabIssue($task, $executionID)
|
||||
{
|
||||
$task->version = 1;
|
||||
$task->openedBy = $this->app->user->account;
|
||||
$task->story = 0;
|
||||
$task->module = 0;
|
||||
$task->estimate = 0;
|
||||
$task->estStarted = '0000-00-00';
|
||||
$task->version = 1;
|
||||
$task->openedBy = $this->app->user->account;
|
||||
$task->assignedDate = isset($task->assignedTo) ? helper::now() : 0;
|
||||
$task->story = 0;
|
||||
$task->module = 0;
|
||||
$task->estimate = 0;
|
||||
$task->estStarted = '0000-00-00';
|
||||
$task->left = 1;
|
||||
$task->type = 'devel';
|
||||
|
||||
if(isset($task->product)) unset($task->product);
|
||||
|
||||
$this->dao->insert(TABLE_TASK)->data($task, $skip = 'id')
|
||||
$this->dao->insert(TABLE_TASK)->data($task, $skip = 'id,product')
|
||||
->autoCheck()
|
||||
->batchCheck($this->config->task->create->requiredFields, 'notempty')
|
||||
->checkIF(!helper::isZeroDate($task->deadline), 'deadline', 'ge', $task->estStarted)
|
||||
->exec();
|
||||
|
||||
if(dao::isError()) return false;
|
||||
|
||||
$taskID = $this->dao->lastInsertID();
|
||||
return $taskID;
|
||||
|
||||
return $this->dao->lastInsertID();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user