* Optimize the loading speed of merge request pages.

This commit is contained in:
caoyanyi
2024-05-13 11:14:48 +08:00
parent e9d9014183
commit 90edee6ce0
3 changed files with 11 additions and 21 deletions
+1 -1
View File
@@ -99,7 +99,7 @@ class mr extends control
$filterProjects = empty($repo->serviceProject) ? array() : array($repo->serviceHost => $repo->serviceProject);
$MRList = $this->mr->getList($mode, $param, $orderBy, $filterProjects, $repoID, 0, $pager);
$projects = $this->mrZen->getAllProjects($repo, $MRList);
$projects = $this->mrZen->getAllProjects($repo);
$this->view->title = $this->lang->mr->common . $this->lang->hyphen . $this->lang->mr->browse;
$this->view->MRList = $MRList;
+8 -5
View File
@@ -122,12 +122,15 @@ class mrModel extends model
$MR = $this->dao->select('min(sourceProject + 0) as minSource, MAX(sourceProject + 0) as maxSource,MIN(targetProject) as minTarget,MAX(targetProject) as maxTarget')->from(TABLE_MR)
->where('deleted')->eq('0')
->andWhere('hostID')->eq($hostID)
->beginIF($projectIdList)->andWhere('sourceProject', true)->in($projectIdList)
->orWhere('targetProject')->in($projectIdList)
->markRight(1)
->fi()
->fetch();
if($MR)
{
$minProject = min($MR->minSource, $MR->minTarget);
$maxProject = max($MR->maxSource, $MR->maxTarget);
}
if(empty($MR->minSource) && empty($MR->minTarget)) return array();
$minProject = min($MR->minSource, $MR->minTarget);
$maxProject = max($MR->maxSource, $MR->maxTarget);
/* If not an administrator, need to obtain group member information. */
$groupIDList = array(0 => 0);
+2 -15
View File
@@ -16,26 +16,13 @@ class mrZen extends mr
* Get the code base project information of the merge request.
*
* @param object $repo
* @param array $MRList
* @access protected
* @return array
*/
protected function getAllProjects(object $repo, array $MRList): array
protected function getAllProjects(object $repo): array
{
$projectIdList = array();
if($repo->SCM == 'Gitlab')
{
foreach($MRList as $MR)
{
if($repo->id != $MR->repoID) continue;
$projectIdList[$MR->sourceProject] = $MR->sourceProject;
$projectIdList[$MR->targetProject] = $MR->targetProject;
}
}
$methodName = 'get' . ucfirst($repo->SCM) . 'Projects';
return $this->mr->{$methodName}((int)$repo->serviceHost, $projectIdList);
return $this->mr->{$methodName}((int)$repo->serviceHost, array($repo->serviceProject => $repo->serviceProject));
}
/**