From a18eb36ab364de078a50ea76f7736561b0eee3b0 Mon Sep 17 00:00:00 2001 From: Lufei Date: Thu, 1 Jun 2023 10:53:13 +0800 Subject: [PATCH] * Optimize program-browse page, Reduce get user. --- module/product/model.php | 2 +- module/program/control.php | 20 ++++++++++++-------- module/program/view/browsebylist.html.php | 5 +++-- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/module/product/model.php b/module/product/model.php index c429702034..2a716dfb4f 100755 --- a/module/product/model.php +++ b/module/product/model.php @@ -1806,7 +1806,7 @@ class productModel extends model ->fetchAll('id'); } - /* Recalculate productKeys after pageing. */ + /* Recalculate productKeys after paging. */ $productKeys = array_keys($products); $linePairs = $this->getLinePairs(); diff --git a/module/program/control.php b/module/program/control.php index 302a431421..a68af7dcd2 100644 --- a/module/program/control.php +++ b/module/program/control.php @@ -31,6 +31,10 @@ class program extends control * * @param string $status * @param string $orderBy + * @param int $recTotal + * @param int $recPerPage + * @param int $pageID + * @param int $param * @access public * @return void */ @@ -55,15 +59,14 @@ class program extends control { if(strtolower($status) == 'bysearch') { - $queryID = (int)$param; - $programs = $this->program->getListBySearch($orderBy, $queryID); + $programs = $this->program->getListBySearch($orderBy, (int)$param); } else { /* Get top programs and projects. */ $topObjects = $this->program->getList($status == 'unclosed' ? 'doing,suspended,wait' : $status, $orderBy, $pager, 'top'); if(!$topObjects) $topObjects = array(0); - $programs = $this->program->getList($status, $orderBy, NULL, 'child', array_keys($topObjects)); + $programs = $this->program->getList($status, $orderBy, null, 'child', array_keys($topObjects)); /* Get summary. */ $topCount = $indCount = 0; @@ -77,12 +80,15 @@ class program extends control } /* Get PM id list. */ - $accounts = array(); + $accounts = array_unique(array_column($programs, 'PM')); $hasProject = false; foreach($programs as $program) { - if(!empty($program->PM) and !in_array($program->PM, $accounts)) $accounts[] = $program->PM; - if($hasProject === false and $program->type != 'program') $hasProject = true; + if($hasProject === false and $program->type != 'program') + { + $hasProject = true; + break; + } } $PMList = $this->loadModel('user')->getListByAccounts($accounts, 'account'); @@ -100,8 +106,6 @@ class program extends control $this->view->summary = isset($summary) ? $summary : ''; $this->view->pager = $pager; $this->view->users = $this->user->getPairs('noletter'); - $this->view->userIdPairs = $this->user->getPairs('noletter|showid'); - $this->view->usersAvatar = $this->user->getAvatarPairs(''); $this->view->programType = $programType; $this->view->PMList = $PMList; $this->view->progressList = $this->program->getProgressList(); diff --git a/module/program/view/browsebylist.html.php b/module/program/view/browsebylist.html.php index 01a87def82..0a2eb6ccc1 100755 --- a/module/program/view/browsebylist.html.php +++ b/module/program/view/browsebylist.html.php @@ -74,9 +74,10 @@ project->statusList, $program->status, '');?> PM)):?> - PM);?> - $usersAvatar[$program->PM], 'account' => $program->PM, 'name' => $userName), (($program->type == 'program' and $program->grade == 1 )? 'avatar-circle avatar-top avatar-' : 'avatar-circle avatar-') . zget($userIdPairs, $program->PM)); ?> PM]) ? $PMList[$program->PM]->id : '';?> + PM]) ? $PMList[$program->PM]->realname : '';?> + PM]) ? $PMList[$program->PM]->avatar : '';?> + $avatar, 'account' => $program->PM, 'name' => $userName), (($program->type == 'program' and $program->grade == 1 )? 'avatar-circle avatar-top avatar-' : 'avatar-circle avatar-') . $userID); ?> createLink('user', 'profile', "userID=$userID", '', true), $userName, '', "title='{$userName}' data-toggle='modal' data-type='iframe' data-width='600'");?>