This commit is contained in:
hufangzhou
2020-10-12 11:09:19 +08:00
3 changed files with 68 additions and 2 deletions
+7
View File
@@ -300,3 +300,10 @@ INSERT INTO `zt_cron` (`m`, `h`, `dom`, `mon`, `dow`, `command`, `remark`, `type
ALTER TABLE `zt_story` ADD `URChanged` enum('0','1') NOT NULL DEFAULT '0' AFTER `version`;
ALTER TABLE `zt_team` MODIFY `type` enum('project','task','stage','sprint') NOT NULL DEFAULT 'project' AFTER `root`;
CREATE TABLE IF NOT EXISTS `zt_planstory` (
`plan` mediumint(8) unsigned NOT NULL,
`story` mediumint(8) unsigned NOT NULL,
`order` mediumint(9) NOT NULL,
UNIQUE KEY `unique` (`plan`,`story`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+59
View File
@@ -611,6 +611,7 @@ class upgradeModel extends model
$this->execSQL($this->getUpgradeFile('20.0'));
$this->setWork2Full();
$this->appendExec('20_0');
$this->initStoryOfPlan();
}
$this->deletePatch();
@@ -4104,4 +4105,62 @@ class upgradeModel extends model
public function appendExec($zentaoVersion)
{
}
/**
* Init story sort of plan.
*
* @access public
* @return void
*/
public function initStoryOfPlan()
{
/* Get all the planned stories and story sort. */
$stories = $this->dao->select('id, plan')->from(TABLE_STORY)->where('plan')->ne(0)->andWhere('plan')->ne('')->orderBy('id_desc')->fetchAll('id');
$planOrder = $this->dao->select('id, `order`')->from(TABLE_PRODUCTPLAN)->where('`order`')->ne('')->fetchAll('id');
/* Organize the stories according to the plan. */
$plans = array();
foreach($stories as $storyID => $story)
{
$planIDList = explode(',', trim($story->plan, ','));
foreach($planIDList as $planID) $plans[$planID][$storyID] = $storyID;
}
foreach($plans as $planID => $storyIDList)
{
/* Order the story according to the plan. */
if(!empty($planOrder[$planID]))
{
$sortIDList = array();
$storySort = explode(',', $planOrder[$planID]->order);
/* Reorder story id list by story order of plan. */
foreach($storySort as $storyID)
{
if(empty($storyID)) continue;
if(!isset($storyIDList[$storyID])) continue;
$sortIDList[$storyID] = $storyID;
unset($storyIDList[$storyID]);
}
if($storyIDList) $sortIDList += $storyIDList;
$storyIDList = $sortIDList;
unset($sortIDList);
}
/* Loop insert sort data by plan. */
$order = 1;
foreach($storyIDList as $storyID)
{
$this->dao->replace(TABLE_PLANSTORY)
->set('plan')->eq($planID)
->set('story')->eq($storyID)
->set('`order`')->eq($order)
->exec();
$order++;
}
}
return true;
}
}
File diff suppressed because one or more lines are too long