From 63479860a52b86bd8cbc7dee6b5a2deb7d1121ad Mon Sep 17 00:00:00 2001 From: songchenxuan Date: Fri, 17 Dec 2021 13:56:24 +0800 Subject: [PATCH] *Finish task #46099. --- module/project/model.php | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/module/project/model.php b/module/project/model.php index 7e72674e3a..3c4f34dd25 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -1824,22 +1824,24 @@ class projectModel extends model ->fetchPairs(); } - $executions = $this->dao->select('*')->from(TABLE_EXECUTION) - ->where('type')->in('sprint,stage') - ->beginIF($projectID != 0)->andWhere('project')->eq($projectID)->fi() - ->beginIF(!empty($myExecutionIDList))->andWhere('id')->in(array_keys($myExecutionIDList))->fi() - ->beginIF($status == 'undone')->andWhere('status')->notIN('done,closed')->fi() - ->beginIF($status != 'all' and $status != 'undone' and $status != 'involved')->andWhere('status')->eq($status)->fi() - ->beginIF(!$this->app->user->admin)->andWhere('id')->in($this->app->user->view->sprints)->fi() - ->andWhere('deleted')->eq('0') + $executions = $this->dao->select('t1.*,t2.name projectName')->from(TABLE_EXECUTION)->alias('t1') + ->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project = t2.id') + ->where('t1.type')->in('sprint,stage') + ->beginIF($projectID != 0)->andWhere('t1.project')->eq($projectID)->fi() + ->beginIF(!empty($myExecutionIDList))->andWhere('t1.id')->in(array_keys($myExecutionIDList))->fi() + ->beginIF($status == 'undone')->andWhere('t1.status')->notIN('done,closed')->fi() + ->beginIF($status != 'all' and $status != 'undone' and $status != 'involved')->andWhere('t1.status')->eq($status)->fi() + ->beginIF(!$this->app->user->admin)->andWhere('t1.id')->in($this->app->user->view->sprints)->fi() + ->andWhere('t1.deleted')->eq('0') ->orderBy($orderBy) ->page($pager) ->fetchAll('id'); } else { - $executions = $this->dao->select('t2.*')->from(TABLE_PROJECTPRODUCT)->alias('t1') + $executions = $this->dao->select('t2.*,t3.name projectName')->from(TABLE_PROJECTPRODUCT)->alias('t1') ->leftJoin(TABLE_EXECUTION)->alias('t2')->on('t1.project=t2.id') + ->leftJoin(TABLE_PROJECT)->alias('t3')->on('t2.project=t3.id') ->where('t1.product')->eq($productID) ->beginIF($projectID)->andWhere('t2.project')->eq($projectID)->fi() ->beginIF($status == 'undone')->andWhere('t2.status')->notIN('done,closed')->fi() @@ -1851,17 +1853,6 @@ class projectModel extends model ->fetchAll('id'); } - $parentIDList = array(); - foreach($executions as $execution) if($execution->parent) array_push($parentIDList, $execution->parent); - $parentNameList = $this->dao->select('id, name')->from(TABLE_EXECUTION) - ->where('id')->in($parentIDList) - ->fetchPairs('id', 'name'); - foreach($executions as $execution) - { - $execution->parentName = ''; - if(isset($parentNameList[$execution->parent])) $execution->parentName = $parentNameList[$execution->parent]; - } - $hours = $this->computerProgress($executions); $emptyHour = array('totalEstimate' => 0, 'totalConsumed' => 0, 'totalLeft' => 0, 'progress' => 0);