* Optimize maintain page speed

This commit is contained in:
zenggang
2023-03-31 06:36:38 +00:00
parent c0ec9f9a9c
commit 2ac25e8aff
2 changed files with 32 additions and 0 deletions
+22
View File
@@ -1034,6 +1034,28 @@ class gitlabModel extends model
return $this->projects[$gitlabID][$projectID];
}
/**
* Multi get projects by repos.
*
* @param object $repos
* @access public
* @return void
*/
public function apiMultiGetProjects($repos)
{
$requests = array();
foreach($repos as $id => $repo)
{
$requests[$id]['url'] = sprintf($this->getApiRoot($repo->serviceHost, false), "/projects/{$repo->serviceProject}");
}
$this->app->loadClass('requests', true);
$results = requests::request_multiple($requests);
foreach($results as $id => $result)
{
if(!empty($result->body) and substr($result->body, 0, 1) == '{') $this->projects[$repos[$id]->serviceHost][$repos[$id]->serviceProject] = json_decode($result->body);
}
}
/**
* Get single user by API.
*