From 6201e68fa7548c50a78e08570f68e147ffb28a44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=80=A1=E6=A0=8B?= Date: Thu, 9 May 2024 13:28:43 +0800 Subject: [PATCH] * Adjust code for task #117451. Batch get data. --- module/program/ui/project.html.php | 17 +++++------------ module/project/zen.php | 8 ++++---- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/module/program/ui/project.html.php b/module/program/ui/project.html.php index 50a453e59b..6f06fb6e0a 100644 --- a/module/program/ui/project.html.php +++ b/module/program/ui/project.html.php @@ -35,23 +35,16 @@ $cols['progress']['sortType'] = false; $projectStats = initTableData($projectStats, $cols, $this->project); -$this->loadModel('story'); -$waitCount = 0; -$doingCount = 0; -$suspendedCount = 0; -$closedCount = 0; +$projectIdList = array_column($projectStats, 'id'); +$storyGroup = $this->loadModel('story')->fetchStoriesByProjectIdList($projectIdList); +$executionGroup = $this->loadModel('execution')->fetchExecutionsByProjectIdList($projectIdList); foreach($projectStats as $project) { - if($project->status == 'wait') $waitCount ++; - if($project->status == 'doing') $doingCount ++; - if($project->status == 'suspended') $suspendedCount ++; - if($project->status == 'closed') $closedCount ++; - - $projectStories = $this->story->getExecutionStories($project->id); + $projectStories = zget($storyGroup, $project->id, array()); $project->storyCount = count($projectStories); $project->storyPoints = round(array_sum(array_column($projectStories, 'estimate')), 2) . ' ' . $this->config->hourUnit; - $executions = $this->loadModel('execution')->getStatData($project->id, 'all'); + $executions = zget($executionGroup, $project->id, array()); $project->executionCount = count($executions); $project = $this->project->formatDataForList($project, $PMList); diff --git a/module/project/zen.php b/module/project/zen.php index a928ff7b15..ee59de7df0 100755 --- a/module/project/zen.php +++ b/module/project/zen.php @@ -1304,19 +1304,19 @@ class projectZen extends project { $userList = $this->dao->select('id,account,realname,avatar')->from(TABLE_USER)->fetchAll('account'); - $this->loadModel('story'); - $this->loadModel('execution'); + $storyGroup = $this->loadModel('story')->fetchStoriesByProjectIdList(array_keys($projectList)); + $executionGroup = $this->loadModel('execution')->fetchExecutionsByProjectIdList(array_keys($projectList)); foreach($projectList as $project) { $project = $this->project->formatDataForList($project, $userList); - $projectStories = $this->story->getExecutionStories($project->id); + $projectStories = zget($storyGroup, $project->id, array()); $project->storyCount = count($projectStories); $project->storyPoints = 0; foreach($projectStories as $story) $project->storyPoints += $story->estimate; $project->storyPoints .= ' ' . $this->config->hourUnit; - $executions = $this->execution->getStatData($project->id, 'all', 0, 0, false, 'skipParent'); + $executions = zget($executionGroup, $project->id, array()); $project->executionCount = count($executions); $project->from = 'project';