From 9a20bab153fb3333c3cd9f3d41b4ce47b57cd4fd Mon Sep 17 00:00:00 2001 From: hufangzhou <746775970@qq.com> Date: Tue, 24 Nov 2020 22:46:33 +0800 Subject: [PATCH] * Finish task#8494. --- module/project/model.php | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/module/project/model.php b/module/project/model.php index 2f5b859edf..97d1412838 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -955,31 +955,27 @@ class projectModel extends model */ public function getExecutionStats($projectID = 0, $status = 'undone', $productID = 0, $branch = 0, $itemCounts = 30, $orderBy = 'order_desc', $pager = null) { - /* Init vars. */ - $executions = $this->getExecutionList($projectID, $status, 0, $productID, $branch); - $executions = $this->dao->select('*')->from(TABLE_EXECUTION) - ->where('id')->in(array_keys($executions)) - ->andWhere('grade')->eq(1) - ->andWhere('deleted')->eq('0') - ->orderBy($orderBy) - ->page($pager) - ->fetchAll('id'); - - if(empty($executions)) return array(); - - /* In case of a waterfall model, obtain sub-stage data. */ - $project = $this->loadModel('program')->getPRJById($this->session->PRJ); - if($project and $project->model == 'waterfall') + if(empty($productID)) { - $childrens = $this->dao->select('*')->from(TABLE_PROJECT) - ->where('parent')->in(array_keys($executions)) - ->andWhere('grade')->eq(2) + $executions = $this->dao->select('*')->from(TABLE_EXECUTION) + ->where('project')->eq($projectID) + ->andWhere('type')->eq('stage') ->andWhere('deleted')->eq('0') - ->orderBy($orderBy) + ->orderBy('path_desc,id_asc') + ->page($pager) + ->fetchAll('id'); + } + else + { + $executions = $this->dao->select('t2.*')->from(TABLE_PROJECTPRODUCT)->alias('t1') + ->leftJoin(TABLE_EXECUTION)->alias('t2')->on('t1.project=t2.id') + ->where('t1.product')->eq($productID) + ->andWhere('t2.project')->eq($projectID) + ->andWhere('t2.type')->eq('stage') + ->andWhere('t2.deleted')->eq('0') + ->orderBy('t2.parent_desc,t2.id_asc') ->page($pager) ->fetchAll('id'); - - $executions += $childrens; } $hours = array(); @@ -1074,6 +1070,7 @@ class projectModel extends model } /* In the case of the waterfall model, calculate the sub-stage. */ + $project = $this->loadModel('program')->getPRJById($this->session->PRJ); if($project and $project->model == 'waterfall') { foreach($parents as $id => $execution) $execution->children = isset($children[$id]) ? $children[$id] : array();