* Optimize program-browse page, Reduce get user.

This commit is contained in:
Lufei
2023-06-01 10:57:44 +08:00
parent bf3fbb6375
commit a18eb36ab3
3 changed files with 16 additions and 11 deletions
+12 -8
View File
@@ -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();