This commit is contained in:
tianshujie
2022-06-16 16:31:01 +08:00
parent d9731bb06c
commit b438c9882a
3 changed files with 67 additions and 13 deletions
-2
View File
@@ -11,5 +11,3 @@ DELETE FROM `zt_workflowaction` WHERE `module`='task' AND `action`='browse';
DELETE FROM `zt_workflowaction` WHERE `module`='build' AND `action`='browse';
ALTER TABLE `zt_projectproduct` MODIFY COLUMN `plan` varchar(255) NOT NULL;
UPDATE `zt_project` SET `grade`=1 WHERE `type` in ('sprint', 'kanban');
+1 -1
View File
@@ -1337,7 +1337,7 @@ class programModel extends model
{
$path = substr($childNode->path, strpos($childNode->path, ",{$programID},"));
/* Only program sets update grade. */
/* Only program and project sets update grade. */
$grade = in_array($childNode->type, array('program', 'project')) ? $childNode->grade - $oldGrade + 1 : $childNode->grade;
if($parent)
{
+66 -10
View File
@@ -513,7 +513,7 @@ class upgradeModel extends model
break;
case '17_0':
$this->replaceSetLanePriv();
$this->updateGradeOfStage();
$this->updateObjectData();
break;
}
@@ -6361,24 +6361,80 @@ class upgradeModel extends model
}
/**
* Update grade of stage.
* Update path and grade of program, project and execution.
*
* @access public
* @return void
* @return bool
*/
public function updateGradeOfStage()
public function updateObjectData()
{
$allStages = $this->dao->select('*')->from(TABLE_EXECUTION)->where('type')->eq('stage')->fetchAll('id');
$updateIDList = array();
foreach($allStages as $stageID => $stage)
/* Process programs. */
$programs = $this->dao->select('id,parent,grade,path')->from(TABLE_PROJECT)->where('type')->eq('program')->orderBy('parent_asc')->fetchAll('id');
foreach($programs as $program)
{
if($stage->project != $stage->parent) $updateIDList[$stageID] = $stageID;
if(!$program->parent)
{
$program->grade = 1;
$program->path = ",$program->id,";
}
else
{
$program->grade = $programs[$program->parent]->grade + 1;
$program->path = $programs[$program->parent]->path . "$program->id,";
}
$this->dao->update(TABLE_PROGRAM)
->set('path')->eq($program->path)
->set('grade')->eq($program->grade)
->where('id')->eq($program->id)->exec();
}
if(!empty($updateIDList))
/* Process projects. */
$projects = $this->dao->select('id,project,parent,grade,path')->from(TABLE_PROJECT)->where('type')->eq('project')->orderBy('parent_asc')->fetchAll('id');
foreach($projects as $project)
{
$this->dao->update(TABLE_EXECUTION)->set('grade')->eq(2)->where('type')->eq('stage')->andWhere('id')->in($updateIDList)->exec();
if(!$project->parent)
{
$project->grade = 1;
$project->path = ",$project->id,";
}
else
{
$project->grade = $programs[$project->parent]->grade + 1;
$project->path = $programs[$project->parent]->path . "$project->id,";
}
$this->dao->update(TABLE_PROJECT)
->set('path')->eq($project->path)
->set('grade')->eq($project->grade)
->where('id')->eq($project->id)->exec();
}
/* Process executions. */
$sprints = $this->dao->select('id,project,parent,grade,path')->from(TABLE_PROJECT)
->where('type')->ne('project')
->andWhere('type')->ne('program')
->orderBy('parent_asc')->fetchAll('id');
foreach($sprints as $sprint)
{
if($sprint->parent == $sprint->project)
{
$sprint->grade = 1;
$sprint->path = ",$sprint->project,$sprint->id,";
}
else
{
$sprint->grade = 2;
$sprint->path = $sprints[$sprint->parent]->path . "$sprint->id,";
}
$this->dao->update(TABLE_EXECUTION)
->set('path')->eq($sprint->path)
->set('grade')->eq($sprint->grade)
->where('id')->eq($sprint->id)->exec();
}
return true;
}
}