This commit is contained in:
tanghucheng
2022-08-24 17:05:46 +08:00
parent f097c7b756
commit bbd1c4ea5e
+45
View File
@@ -547,6 +547,7 @@ class upgradeModel extends model
$this->updateOSAndBrowserOfBug();
$this->addURPriv();
$this->updateStoryStatus();
if(strpos($fromVersion, 'max') !== false) $this->syncCase2Project();
break;
}
@@ -7157,4 +7158,48 @@ class upgradeModel extends model
$this->dbh->exec($sql);
return true;
}
/**
* Sync case to project|execution if case create from import.
*
* @access public
* @return void
*/
public function syncCase2Project()
{
$linkStoryCases = $this->dao->select('id, story, version, product')->from(TABLE_CASE)->where('story')->ne('0')->fetchAll('id');
$linkProjectCases = $this->dao->select('`case`, project')->from(TABLE_PROJECTCASE)->where('`case`')->ne('0')->andWhere('project')->ne('0')->fetchGroup('case', 'project');
if(empty($linkStoryCases)) return true;
$projectList = $this->dao->select('t1.project, t1.story, t1.product')->from(TABLE_PROJECTSTORY)->alias('t1')
->leftjoin(TABLE_PROJECT)->alias('t2')->on('t1.project=t2.id')
->where('t2.status')->ne('closed')
->fetchGroup('story', 'project');
if(empty($projectList)) return true;
foreach($linkStoryCases as $caseID => $case)
{
/* If story unlink project continue. */
if(!isset($projectList[$case->story])) continue;
$storyProjects = $projectList[$case->story];
$lastOrder = 1;
foreach($storyProjects as $projectID => $value)
{
/* If case linked project continue.*/
if(isset($linkProjectCases[$caseID][$projectID])) continue;
$data = new stdclass();
$data->project = $projectID;
$data->product = $case->product;
$data->case = $caseID;
$data->version = $case->version;
$data->order = $lastOrder ++;
$this->dao->insert(TABLE_PROJECTCASE)->data($data)->exec();
}
}
}
}