From 86439a699ec3ed726053582f1d11fac38b363c99 Mon Sep 17 00:00:00 2001 From: chenfeiCF Date: Thu, 17 Nov 2016 11:22:14 +0800 Subject: [PATCH] * finish task #2695. --- module/bug/model.php | 35 +++++++++++++++++++++ module/product/control.php | 10 ++++++ module/product/view/browse.html.php | 3 +- module/product/view/browsedata.html.php | 41 +++++++++++++++++++------ module/story/control.php | 30 ++++++++++++++++++ module/story/lang/en.php | 3 ++ module/story/lang/zh-cn.php | 3 ++ module/testcase/model.php | 35 +++++++++++++++++++++ 8 files changed, 149 insertions(+), 11 deletions(-) diff --git a/module/bug/model.php b/module/bug/model.php index 1b285a1eec..3982769215 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -1213,6 +1213,41 @@ class bugModel extends model return $bugs; } + /** + * Get bugs of a story. + * + * @param int $storyID + * @access public + * @return array + */ + public function getStoryBugs($storyID) + { + return $this->dao->select('id, title, type, status, assignedTo, resolvedBy, resolution') + ->from(TABLE_BUG) + ->where('story')->eq((int)$storyID) + ->andWhere('deleted')->eq(0) + ->fetchAll('id'); + } + + /** + * Get counts of some stories' bugs. + * + * @param array $stories + * @access public + * @return int + */ + public function getStoryBugCounts($stories) + { + $bugCounts = $this->dao->select('story, COUNT(*) AS bugs') + ->from(TABLE_BUG) + ->where('story')->in($stories) + ->andWhere('deleted')->eq(0) + ->groupBy('story') + ->fetchPairs(); + foreach($stories as $storyID) if(!isset($bugCounts[$storyID])) $bugCounts[$storyID] = 0; + return $bugCounts; + } + /** * Get bug info from a result. * diff --git a/module/product/control.php b/module/product/control.php index efbf3b0047..499b2bb393 100644 --- a/module/product/control.php +++ b/module/product/control.php @@ -159,6 +159,13 @@ class product extends control /* Process the sql, get the conditon partion, save it to session. */ $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'story'); + /* Get related tasks, bugs, cases count of each story. */ + $storyIdList = array(); + foreach($stories as $story) $storyIdList[$story->id] = $story->id; + $storyTasks = $this->loadModel('task')->getStoryTaskCounts($storyIdList); + $storyBugs = $this->loadModel('bug')->getStoryBugCounts($storyIdList); + $storyCases = $this->loadModel('testcase')->getStoryCaseCounts($storyIdList); + /* Build search form. */ $actionURL = $this->createLink('product', 'browse', "productID=$productID&branch=$branch&browseType=bySearch&queryID=myQueryID"); $this->config->product->search['onMenuBar'] = 'yes'; @@ -191,6 +198,9 @@ class product extends control $this->view->branches = $this->loadModel('branch')->getPairs($productID); $this->view->storyStages = $this->product->batchGetStoryStage($stories); $this->view->setShowModule = true; + $this->view->storyTasks = $storyTasks; + $this->view->storyBugs = $storyBugs; + $this->view->storyCases = $storyCases; $this->view->param = $param; $this->display(); } diff --git a/module/product/view/browse.html.php b/module/product/view/browse.html.php index 62e8f8b693..c9e30f2906 100644 --- a/module/product/view/browse.html.php +++ b/module/product/view/browse.html.php @@ -12,6 +12,7 @@ ?> +