From 6edb5fe805857e71f3da82890142e88fc7d676f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=80=A1=E6=A0=8B?= Date: Sat, 2 Apr 2022 14:44:18 +0800 Subject: [PATCH] * fix bug #21413. --- module/execution/model.php | 1 + module/task/model.php | 78 +++++++++++++++++++++----------------- 2 files changed, 44 insertions(+), 35 deletions(-) diff --git a/module/execution/model.php b/module/execution/model.php index f14c3cc059..37a8107aaf 100644 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -3005,6 +3005,7 @@ class executionModel extends model } $parents = $this->dao->select('*')->from(TABLE_TASK)->where('id')->in($parents)->fetchAll('id'); + if($this->config->vision == 'lite') $tasks = $this->loadModel('task')->appendLane($tasks); foreach($tasks as $task) { if($task->parent > 0) diff --git a/module/task/model.php b/module/task/model.php index f959536a27..5316974064 100644 --- a/module/task/model.php +++ b/module/task/model.php @@ -2198,41 +2198,7 @@ class taskModel extends model } $parents = $this->dao->select('*')->from(TABLE_TASK)->where('id')->in($parents)->fetchAll('id'); - if ($this->config->vision == 'lite') { - $lanes = array(); - $cardsWhere = ''; - foreach($tasks as $task) - { - if(empty($cardsWhere)) - { - $cardsWhere = "cards like '%,{$task->id},%'"; - } - else - { - $cardsWhere .= " or cards like '%,{$task->id},%'"; - } - } - $lanes = $this->dao->select('t1.lane,t2.name,t1.cards') - ->from(TABLE_KANBANCELL)->alias('t1') - ->leftJoin(TABLE_KANBANLANE)->alias('t2')->on('t1.lane = t2.id') - ->where('t1.kanban')->eq($executionID) - ->andWhere('t2.deleted')->eq(0) - ->andWhere("($cardsWhere)") - ->fetchAll(); - - foreach($tasks as $task) - { - $task->lane = ''; - if(!empty($lanes)) - { - foreach($lanes as $lane) - { - if(strpos($lane->cards, ",{$task->id},") !== false) $task->lane = $lane->name; - } - } - } - } - + if($this->config->vision == 'lite') $tasks = $this->appendLane($tasks); foreach($tasks as $task) { if($task->parent > 0) @@ -2681,6 +2647,48 @@ class taskModel extends model if(!dao::isError()) return common::createChanges($oldTask, $newTask); } + /** + * Append lane field to tasks; + * + * @param array $tasks + * @access public + * @return array + */ + public function appendLane($tasks) + { + $executionIdList = array(); + foreach($tasks as $task) + { + $task->lane = ''; + if(!isset($executionIdList[$task->execution])) $executionIdList[$task->execution] = $task->execution; + } + + $lanes = $this->dao->select('t1.kanban,t1.lane,t2.name,t1.cards')->from(TABLE_KANBANCELL)->alias('t1') + ->leftJoin(TABLE_KANBANLANE)->alias('t2')->on('t1.lane = t2.id') + ->where('t1.kanban')->in($executionIdList) + ->andWhere('t2.deleted')->eq(0) + ->andWhere('t1.type')->eq('task') + ->andWhere("t1.cards")->ne('') + ->fetchAll(); + + if(empty($lanes)) return $tasks; + + foreach($tasks as $task) + { + foreach($lanes as $lane) + { + if($lane->kanban != $task->execution) continue; + if(strpos(",{$lane->cards},", ",{$task->id},") !== false) + { + $task->lane = $lane->name; + break; + } + } + } + + return $tasks; + } + /** * Batch process tasks. *