From 1b8db9c5002f38774a5a4cf4d6c3a1103a9f0a69 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Thu, 28 Oct 2021 14:18:18 +0800 Subject: [PATCH 1/4] * Update Kanban cards. --- module/kanban/model.php | 146 +++++++++++++++++++++++----------------- 1 file changed, 86 insertions(+), 60 deletions(-) diff --git a/module/kanban/model.php b/module/kanban/model.php index 30857b5dc8..adc23ac328 100644 --- a/module/kanban/model.php +++ b/module/kanban/model.php @@ -31,6 +31,8 @@ class kanbanModel extends model if(empty($lanes)) return array(); + foreach($lanes as $lane) $this->updateCards($executionID, $lane); + $columns = $this->dao->select('*')->from(TABLE_KANBANCOLUMN) ->where('deleted')->eq(0) ->andWhere('lane')->in(array_keys($lanes)) @@ -62,7 +64,7 @@ class kanbanModel extends model $laneData['order'] = $lane->order; $laneData['defaultCardType'] = $laneType; - foreach($columns[$laneID] as $columnID => $column) + foreach($columns[$laneID] as $colID => $column) { $columnData[$column->id]['id'] = $laneType . '-' . $column->type; $columnData[$column->id]['type'] = $column->type; @@ -249,92 +251,116 @@ class kanbanModel extends model * Update column cards. * * @param int $executionID - * @param string $objectType story|bug|task - * @param object $columns + * @param object $lane * @access public * @return void */ - public function updateCards($executionID, $objectType, $columns) + public function updateCards($executionID, $lane) { - $objects = array(); - if($objectType == 'story') $objects = $this->loadModel('story')->getExecutionStories($executionID); - if($objectType == 'bug') $objects = $this->loadModel('bug')->getExecutionBugs($executionID); - if($objectType == 'task') $objects = $this->loadModel('execution')->getKanbanTasks($executionID); - if($objectType == 'story') + $laneType = $lane->type; + $cardPairs = $this->dao->select('*')->from(TABLE_KANBANCOLUMN) + ->where('deleted')->eq(0) + ->andWhere('lane')->eq($lane->id) + ->fetchPairs('type' ,'cards'); + + if($laneType == 'story') { - $data = new stdClass(); - foreach($columns as $colID => $col) + $stories = $this->loadModel('story')->getExecutionStories($executionID); + foreach($stories as $storyID => $story) { - foreach($objects as $storyID => $story) + foreach($this->config->kanban->storyColumnStageList as $colType => $stage) { - if($col->type == 'backlog' and $story->status == 'active' and $story->stage == 'projected') $data->cards .= $storyID . ','; - - if($colType == 'closed' and $story->status == 'closed' and $story->stage == 'closed') $data->cards .= $storyID . ','; - - if($story->stage == $colType and strpos(',backlog,closed,', $colType) === false and $story->status == 'active') $data->cards .= $storyID . ','; + if(strpos(',ready,develop,test,', $colType) !== false) continue; + if($colType == 'backlog' and $story->stage == $stage and strpos($cardPairs['ready'], ",$storyID,") === false and strpos($cardPairs['backlog'], ",$storyID,") === false) + { + foreach($cardPairs as $type => $cards) + { + if(strpos($cards, ",$storyID,") !== false) $cardPairs[$type] = str_replace(",$storyID,", ',', $cardPairs[$colType]); + } + $cardPairs['backlog'] .= empty($cardPairs['backlog']) ? ',' . $storyID . ',' : $storyID . ','; + } + elseif($story->stage == $stage and strpos($cardPairs[$colType], ",$storyID,") === false) + { + foreach($cardPairs as $type => $cards) + { + if(strpos($cards, ",$storyID,") !== false) $cardPairs[$type] = str_replace(",$storyID,", ',', $cardPairs[$colType]); + } + $cardPairs[$colType] .= empty($cardPairs[$colType]) ? ',' . $storyID . ',' : $storyID . ','; + } } - if(!empty($data->cards)) $data->cards = ',' . $data->cards; } - $this->dao->insert(TABLE_KANBANCOLUMN)->data($data)->exec(); - if($colType == 'develop') $devColumnID = $this->dao->lastInsertId(); - if($colType == 'test') $testColumnID = $this->dao->lastInsertId(); } - elseif($type == 'bug') + elseif($laneType == 'bug') { - foreach($this->lang->kanban->bugColumn as $colType => $name) + $bugs = $this->loadModel('bug')->getExecutionBugs($executionID); + foreach($bugs as $bugID => $bug) { - $data = new stdClass(); - $data->lane = $laneID; - $data->name = $name; - $data->type = $colType; - $data->cards = ''; - if(strpos(',fixing,fixed,', $colType) !== false) $data->parent = $resolvingColumnID; - if(strpos(',testing,tested,', $colType) !== false) $data->parent = $testColumnID; - if(strpos(',resolving,fixing,test,testing,tested,', $colType) === false) + $existed = false; + foreach($this->config->kanban->bugColumnStatusList as $colType => $status) { - foreach($objects as $bugID => $bug) + if(strpos(',resolving,fixing,test,testing,tested,', $colType) !== false) continue; + if($colType == 'unconfirmed' and $bug->status == $status and $bug->confirmed == 0 and strpos($cardPairs['unconfirmed'], ",$bugID,") === false) { - if($colType == 'unconfirmed' and $bug->status == 'active' and $bug->confirmed == 0) $data->cards .= $bugID . ','; - - if($colType == 'confirmed' and $bug->status == 'active' and $bug->confirmed == 1) $data->cards .= $bugID . ','; - - if($colType == 'fixed' and $bug->status == 'resolved') $data->cards .= $bugID . ','; - - if($colType == 'closed' and $bug->status == 'closed') $data->cards .= $bugID . ','; + foreach($cardPairs as $type => $cards) + { + if(strpos($cards, ",$bugID,") !== false) $existed = true; + } + if(!$existed) + { + $cardPairs['unconfirmed'] .= empty($cardPairs['unconfirmed']) ? ',' . $bugID . ',' : $bugID . ','; + } + } + elseif($colType == 'confirmed' and $bug->status == $status and $bug->confirmed == 1 and strpos($cardPairs['confirmed'], ",$bugID,") === false) + { + if(strpos($cardcardPairs['unconfirmed'], ",$bugID,") !== false) + { + $cardPairs['unconfirmed'] = str_replace(",$bugID,", ',', $cardPairs['unconfirmed']); + } + foreach($cardPairs as $type => $cards) + { + if(strpos($cards, ",$bugID,") !== false) $existed = true; + } + if(!$existed) + { + $cardPairs['confirmed'] .= empty($cardPairs['confirmed']) ? ',' . $bugID . ',' : $bugID . ','; + } + } + elseif($bug->status == $status and strpos($cardPairs[$colType], ",$bugID,") === false) + { + foreach($cardPairs as $type => $cards) + { + if(strpos($cards, ",$bugID,") !== false) $cardPairs[$type] = str_replace(",$bugID,", ',', $cardPairs[$colType]); + } + $cardPairs[$colType] .= empty($cardPairs[$colType]) ? ',' . $bugID . ',' : $bugID . ','; } - $this->dao->insert(TABLE_KANBANCOLUMN)->data($data)->exec(); - if($colType == 'resolving') $resolvingColumnID = $this->dao->lastInsertId(); - if($colType == 'test') $testColumnID = $this->dao->lastInsertId(); } } } - elseif($type == 'task') + elseif($laneType == 'task') { - foreach($this->lang->kanban->taskColumn as $colType => $name) + $tasks = $this->loadModel('execution')->getKanbanTasks($executionID); + foreach($tasks as $taskID => $task) { - $data = new stdClass(); - $data->lane = $laneID; - $data->name = $name; - $data->type = $colType; - $data->cards = ''; - if(strpos(',developing,developed,', $colType) !== false) $data->parent = $devColumnID; - if(strpos(',develop,', $colType) === false) + foreach($this->config->kanban->taskColumnStatusList as $colType => $status) { - foreach($objects as $taskID => $task) + if($colType == 'develop') continue; + if($task->status == $status and strpos($cardPairs[$colType], ",$taskID,") === false) { - if($colType == 'developing' and $task->status == 'doing') $data->cards .= $taskID . ','; - - if($colType == 'developed' and $task->status == 'done') $data->cards .= $taskID . ','; - - if(strpos(',wait,pause,canceled,closed,', $colType) !== false and $task->status == $colType) $data->cards .= $taskID . ','; + foreach($cardPairs as $type => $cards) + { + if(strpos($cards, ",$taskID,") !== false) $cardPairs[$type] = str_replace(",$taskID,", ',', $cardPairs[$colType]); + } + $cardPairs[$colType] .= empty($cardPairs[$colType]) ? ',' . $taskID . ',' : $taskID . ','; } - - $this->dao->insert(TABLE_KANBANCOLUMN)->data($data)->exec(); - if($colType == 'develop') $devColumnID = $this->dao->lastInsertId(); } } } + + foreach($cardPairs as $colType => $cards) + { + $this->dao->update(TABLE_KANBANCOLUMN)->set('cards')->eq($cards)->where('lane')->eq($lane->id)->andWhere('type')->eq($colType)->exec(); + } } /** From ded3d0551a0e8a75a0727858eb190e33c0c9158b Mon Sep 17 00:00:00 2001 From: tianshujie Date: Thu, 28 Oct 2021 14:52:54 +0800 Subject: [PATCH 2/4] * Adjust and update card logic. --- module/kanban/model.php | 67 +++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 43 deletions(-) diff --git a/module/kanban/model.php b/module/kanban/model.php index adc23ac328..57a116d4ca 100644 --- a/module/kanban/model.php +++ b/module/kanban/model.php @@ -31,7 +31,7 @@ class kanbanModel extends model if(empty($lanes)) return array(); - foreach($lanes as $lane) $this->updateCards($executionID, $lane); + foreach($lanes as $lane) $this->updateCards($lane); $columns = $this->dao->select('*')->from(TABLE_KANBANCOLUMN) ->where('deleted')->eq(0) @@ -250,14 +250,14 @@ class kanbanModel extends model /** * Update column cards. * - * @param int $executionID * @param object $lane * @access public * @return void */ - public function updateCards($executionID, $lane) + public function updateCards($lane) { - $laneType = $lane->type; + $laneType = $lane->type; + $executionID = $lane->type; $cardPairs = $this->dao->select('*')->from(TABLE_KANBANCOLUMN) ->where('deleted')->eq(0) ->andWhere('lane')->eq($lane->id) @@ -273,23 +273,18 @@ class kanbanModel extends model if(strpos(',ready,develop,test,', $colType) !== false) continue; if($colType == 'backlog' and $story->stage == $stage and strpos($cardPairs['ready'], ",$storyID,") === false and strpos($cardPairs['backlog'], ",$storyID,") === false) { - foreach($cardPairs as $type => $cards) - { - if(strpos($cards, ",$storyID,") !== false) $cardPairs[$type] = str_replace(",$storyID,", ',', $cardPairs[$colType]); - } $cardPairs['backlog'] .= empty($cardPairs['backlog']) ? ',' . $storyID . ',' : $storyID . ','; } elseif($story->stage == $stage and strpos($cardPairs[$colType], ",$storyID,") === false) { - foreach($cardPairs as $type => $cards) - { - if(strpos($cards, ",$storyID,") !== false) $cardPairs[$type] = str_replace(",$storyID,", ',', $cardPairs[$colType]); - } $cardPairs[$colType] .= empty($cardPairs[$colType]) ? ',' . $storyID . ',' : $storyID . ','; } + elseif($story->stage != $stage and strpos($cardPairs[$colType], ",$storyID,") !== false) + { + $cardPairs[$colType] = str_replace(",$storyID,", ',', $cardPairs[$colType]); + } } } - } elseif($laneType == 'bug') { @@ -300,40 +295,26 @@ class kanbanModel extends model foreach($this->config->kanban->bugColumnStatusList as $colType => $status) { if(strpos(',resolving,fixing,test,testing,tested,', $colType) !== false) continue; - if($colType == 'unconfirmed' and $bug->status == $status and $bug->confirmed == 0 and strpos($cardPairs['unconfirmed'], ",$bugID,") === false) + if($colType == 'unconfirmed' and $bug->status == $status and $bug->confirmed == 0 and strpos($cardPairs['unconfirmed'], ",$bugID,") === false and strpos($cardPairs['fixing'], ",$bugID,") === false) { - foreach($cardPairs as $type => $cards) - { - if(strpos($cards, ",$bugID,") !== false) $existed = true; - } - if(!$existed) - { - $cardPairs['unconfirmed'] .= empty($cardPairs['unconfirmed']) ? ',' . $bugID . ',' : $bugID . ','; - } + $cardPairs['unconfirmed'] .= empty($cardPairs['unconfirmed']) ? ',' . $bugID . ',' : $bugID . ','; } - elseif($colType == 'confirmed' and $bug->status == $status and $bug->confirmed == 1 and strpos($cardPairs['confirmed'], ",$bugID,") === false) + elseif($colType == 'confirmed' and $bug->status == $status and $bug->confirmed == 1 and strpos($cardPairs['confirmed'], ",$bugID,") === false and strpos($cardPairs['fixing'], ",$bugID,") === false) { - if(strpos($cardcardPairs['unconfirmed'], ",$bugID,") !== false) - { - $cardPairs['unconfirmed'] = str_replace(",$bugID,", ',', $cardPairs['unconfirmed']); - } - foreach($cardPairs as $type => $cards) - { - if(strpos($cards, ",$bugID,") !== false) $existed = true; - } - if(!$existed) - { - $cardPairs['confirmed'] .= empty($cardPairs['confirmed']) ? ',' . $bugID . ',' : $bugID . ','; - } + $cardPairs['confirmed'] .= empty($cardPairs['confirmed']) ? ',' . $bugID . ',' : $bugID . ','; + } + elseif($colType == 'fixed' and $bug->status == $status and strpos($cardPairs['fixed'], ",$bugID,") === false and strpos($cardPairs['testing'], ",$bugID,") === false and strpos($cardPairs['tested'], ",$bugID,") === false) + { + $cardPairs['confirmed'] .= empty($cardPairs['confirmed']) ? ',' . $bugID . ',' : $bugID . ','; } elseif($bug->status == $status and strpos($cardPairs[$colType], ",$bugID,") === false) { - foreach($cardPairs as $type => $cards) - { - if(strpos($cards, ",$bugID,") !== false) $cardPairs[$type] = str_replace(",$bugID,", ',', $cardPairs[$colType]); - } $cardPairs[$colType] .= empty($cardPairs[$colType]) ? ',' . $bugID . ',' : $bugID . ','; } + elseif($bug->status != $status and strpos($cardPairs[$colType], ",$bugID,") !== false) + { + $cardPairs[$colType] = str_replace(",$bugID,", ',', $cardPairs[$colType]); + } } } } @@ -347,12 +328,12 @@ class kanbanModel extends model if($colType == 'develop') continue; if($task->status == $status and strpos($cardPairs[$colType], ",$taskID,") === false) { - foreach($cardPairs as $type => $cards) - { - if(strpos($cards, ",$taskID,") !== false) $cardPairs[$type] = str_replace(",$taskID,", ',', $cardPairs[$colType]); - } $cardPairs[$colType] .= empty($cardPairs[$colType]) ? ',' . $taskID . ',' : $taskID . ','; } + elseif($task->status != $status and strpos($cardPairs[$colType], ",$taskID,") !== false) + { + $cardPairs[$colType] = str_replace(",$taskID,", ',', $cardPairs[$colType]); + } } } } From 6fefaaaead1af900f096211422a099c5332c2c9a Mon Sep 17 00:00:00 2001 From: tianshujie Date: Thu, 28 Oct 2021 14:56:58 +0800 Subject: [PATCH 3/4] * Modify the variable name of the kanban column. --- module/kanban/model.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/kanban/model.php b/module/kanban/model.php index 57a116d4ca..dee36f14b1 100644 --- a/module/kanban/model.php +++ b/module/kanban/model.php @@ -64,7 +64,7 @@ class kanbanModel extends model $laneData['order'] = $lane->order; $laneData['defaultCardType'] = $laneType; - foreach($columns[$laneID] as $colID => $column) + foreach($columns[$laneID] as $columnID => $column) { $columnData[$column->id]['id'] = $laneType . '-' . $column->type; $columnData[$column->id]['type'] = $column->type; From 4edfddbc5235b168f68529e22ffc957c92a50c41 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Thu, 28 Oct 2021 15:03:02 +0800 Subject: [PATCH 4/4] * Modify the variable name of the kanban column. --- module/kanban/model.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/module/kanban/model.php b/module/kanban/model.php index dee36f14b1..d422ca33e7 100644 --- a/module/kanban/model.php +++ b/module/kanban/model.php @@ -257,7 +257,7 @@ class kanbanModel extends model public function updateCards($lane) { $laneType = $lane->type; - $executionID = $lane->type; + $executionID = $lane->exeuction; $cardPairs = $this->dao->select('*')->from(TABLE_KANBANCOLUMN) ->where('deleted')->eq(0) ->andWhere('lane')->eq($lane->id) @@ -291,7 +291,6 @@ class kanbanModel extends model $bugs = $this->loadModel('bug')->getExecutionBugs($executionID); foreach($bugs as $bugID => $bug) { - $existed = false; foreach($this->config->kanban->bugColumnStatusList as $colType => $status) { if(strpos(',resolving,fixing,test,testing,tested,', $colType) !== false) continue;