From fcc10e1d709d03bdfe157a9902139086a0f6f1a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Mon, 15 Dec 2025 12:14:42 +0100 Subject: [PATCH] Added fetchLimit overrides to EGG --- www/extern/egg/ExtendedGitGraph2.php | 26 +++++++++++++++++---- www/extern/egg/IConfigSource.php | 9 +++++++ www/extern/egg/Logger.php | 2 +- www/extern/egg/RemoteSource.php | 18 +++++++++----- www/extern/egg/RemoteSourceGitea.php | 13 ++++++----- www/extern/egg/RemoteSourceGithub.php | 11 +++++---- www/internals/modules/mikeschergitgraph.php | 5 ++++ www/shell/extendedgitgraph_refresh.php | 8 +++++++ 8 files changed, 69 insertions(+), 23 deletions(-) create mode 100644 www/extern/egg/IConfigSource.php diff --git a/www/extern/egg/ExtendedGitGraph2.php b/www/extern/egg/ExtendedGitGraph2.php index a319f12..8446144 100644 --- a/www/extern/egg/ExtendedGitGraph2.php +++ b/www/extern/egg/ExtendedGitGraph2.php @@ -1,5 +1,6 @@ logger []= new SessionLogger($config['session_var']); if ($config['output_stdout']) $this->logger []= new OutputLogger(); if ($config['output_logfile']) $this->logger []= new FileLogger($config['logfile'], $config['logfile_count']); - if ($config['output_file']) $this->logger []= new SingleFileLogger($config['output_filepath']); + if ($config['output_file']) $this->logger []= new SingleFileLogger($config['output_filepath']); + + if (isset($config['fetchlimit_commits'])) $this->fetchLimitCommits = intval($config['fetchlimit_commits']); + if (isset($config['fetchlimit_branches'])) $this->fetchLimitBranches = intval($config['fetchlimit_branches']); + if (isset($config['fetchlimit_repos'])) $this->fetchLimitRepos = intval($config['fetchlimit_repos']); + if (isset($config['fetchlimit_orgs'])) $this->fetchLimitOrgs = intval($config['fetchlimit_orgs']); $this->sources = []; @@ -42,9 +53,9 @@ class ExtendedGitGraph2 implements ILogger { $newsrc = null; if ($rmt['type'] === 'github') - $newsrc = new GithubConnection($this, $rmt['name'], $rmt['url'], $rmt['filter'], $rmt['exclusions'], $rmt['oauth_id'], $rmt['oauth_secret'], $rmt['token_cache'] ); + $newsrc = new GithubConnection($this, $this, $rmt['name'], $rmt['url'], $rmt['filter'], $rmt['exclusions'], $rmt['oauth_id'], $rmt['oauth_secret'], $rmt['token_cache'] ); else if ($rmt['type'] === 'gitea') - $newsrc = new GiteaConnection($this, $rmt['name'], $rmt['url'], $rmt['filter'], $rmt['exclusions'], $rmt['username'], $rmt['password'] ); + $newsrc = new GiteaConnection($this, $this, $rmt['name'], $rmt['url'], $rmt['filter'], $rmt['exclusions'], $rmt['username'], $rmt['password'] ); else throw new EGGException("Unknown remote-type: " . $rmt['type']); @@ -59,6 +70,11 @@ class ExtendedGitGraph2 implements ILogger $this->outputter = new FullRenderer($this, $config['identities'], $config['output_cache_files']); } + public function getFetchLimitCommits(): int { return $this->fetchLimitCommits; } + public function getFetchLimitBranches(): int { return $this->fetchLimitBranches; } + public function getFetchLimitRepos(): int { return $this->fetchLimitRepos; } + public function getFetchLimitOrgs(): int { return $this->fetchLimitOrgs; } + public function update() { try diff --git a/www/extern/egg/IConfigSource.php b/www/extern/egg/IConfigSource.php new file mode 100644 index 0000000..2216f9b --- /dev/null +++ b/www/extern/egg/IConfigSource.php @@ -0,0 +1,9 @@ +logger = $logger; + $this->logger = $logger; + $this->cfgSource = $cfg; $this->name = $name; $this->filter = $filter; $this->exclusions = $exclusions; diff --git a/www/extern/egg/RemoteSourceGitea.php b/www/extern/egg/RemoteSourceGitea.php index 4e89b0e..b235338 100644 --- a/www/extern/egg/RemoteSourceGitea.php +++ b/www/extern/egg/RemoteSourceGitea.php @@ -1,5 +1,6 @@ url = $url; $this->username = $username; @@ -55,28 +56,28 @@ class GiteaConnection extends StandardGitConnection /** @inheritDoc */ protected function queryOrganizations($page) { - $url = Utils::sharpFormat(Utils::urlCombine($this->url, self::API_BASE_URL, self::API_USER_ORG_LIST), ['page'=>$page, 'limit'=>64 ]); + $url = Utils::sharpFormat(Utils::urlCombine($this->url, self::API_BASE_URL, self::API_USER_ORG_LIST), ['page'=>$page, 'limit'=>$this->cfgSource->getFetchLimitOrgs() ]); return Utils::getJSONWithTokenBasicAuth($this->logger, $url, $this->username, $this->password); } /** @inheritDoc */ protected function queryRepositories($user, $page) { - $url = Utils::sharpFormat(Utils::urlCombine($this->url, self::API_BASE_URL, self::API_USER_REPO_LIST), ['user'=>$user, 'page'=>$page, 'limit'=>64 ]); + $url = Utils::sharpFormat(Utils::urlCombine($this->url, self::API_BASE_URL, self::API_USER_REPO_LIST), ['user'=>$user, 'page'=>$page, 'limit'=>$this->cfgSource->getFetchLimitRepos() ]); return Utils::getJSONWithTokenBasicAuth($this->logger, $url, $this->username, $this->password); } /** @inheritDoc */ protected function queryBranches($reponame, $page) { - $url = Utils::sharpFormat(Utils::urlCombine($this->url, self::API_BASE_URL, self::API_BRANCH_LIST), ['repo'=>$reponame, 'page'=>$page, 'limit'=>64]); + $url = Utils::sharpFormat(Utils::urlCombine($this->url, self::API_BASE_URL, self::API_BRANCH_LIST), ['repo'=>$reponame, 'page'=>$page, 'limit'=>$this->cfgSource->getFetchLimitBranches()]); return Utils::getJSONWithTokenBasicAuth($this->logger, $url, $this->username, $this->password); } /** @inheritDoc */ protected function queryCommits($reponame, $branchname, $startsha) { - $url = Utils::sharpFormat(Utils::urlCombine($this->url, self::API_BASE_URL, self::API_COMMIT_LIST), [ 'repo'=>$reponame, 'sha'=>$startsha, 'limit'=>1024 ]); + $url = Utils::sharpFormat(Utils::urlCombine($this->url, self::API_BASE_URL, self::API_COMMIT_LIST), [ 'repo'=>$reponame, 'sha'=>$startsha, 'limit'=>$this->cfgSource->getFetchLimitCommits() ]); return Utils::getJSONWithTokenBasicAuth($this->logger, $url, $this->username, $this->password); } diff --git a/www/extern/egg/RemoteSourceGithub.php b/www/extern/egg/RemoteSourceGithub.php index 459132c..cd169c4 100644 --- a/www/extern/egg/RemoteSourceGithub.php +++ b/www/extern/egg/RemoteSourceGithub.php @@ -1,5 +1,6 @@ url = $url; $this->oauth_id = $oauth_id; @@ -95,21 +96,21 @@ class GithubConnection extends StandardGitConnection /** @inheritDoc */ protected function queryRepositories($user, $page) { - $url = Utils::sharpFormat(self::API_REPOSITORIESLIST, ['user'=>$user, 'page'=>$page]); + $url = Utils::sharpFormat(self::API_REPOSITORIESLIST, ['user'=>$user, 'page'=>$page, 'per_page'=>$this->cfgSource->getFetchLimitRepos() ]); return Utils::getJSONWithTokenAuth($this->logger, $url, $this->apitoken); } /** @inheritDoc */ protected function queryBranches($reponame, $page) { - $url = Utils::sharpFormat(self::API_BRANCHLIST, ['repo'=>$reponame, 'page'=>$page]); + $url = Utils::sharpFormat(self::API_BRANCHLIST, ['repo'=>$reponame, 'page'=>$page, 'per_page'=>$this->cfgSource->getFetchLimitBranches() ]); return Utils::getJSONWithTokenAuth($this->logger, $url, $this->apitoken); } /** @inheritDoc */ protected function queryCommits($reponame, $branchname, $startsha) { - $url = Utils::sharpFormat(self::API_COMMITSLIST, [ 'repo'=>$reponame, 'sha'=>$startsha ]); + $url = Utils::sharpFormat(self::API_COMMITSLIST, [ 'repo'=>$reponame, 'sha'=>$startsha, 'per_page'=>$this->cfgSource->getFetchLimitCommits() ]); return Utils::getJSONWithTokenAuth($this->logger, $url, $this->apitoken); } diff --git a/www/internals/modules/mikeschergitgraph.php b/www/internals/modules/mikeschergitgraph.php index 62f2e63..b93bbae 100644 --- a/www/internals/modules/mikeschergitgraph.php +++ b/www/internals/modules/mikeschergitgraph.php @@ -14,6 +14,11 @@ class MikescherGitGraph implements IWebsiteModule $this->extgitgraph = new ExtendedGitGraph2($egh_conf); } + public function setFetchLimitCommits(int $flo) + { + $this->extgitgraph->fetchLimitCommits = $flo; + } + public function getPathRenderedData(): string { return __DIR__ . '/../../dynamic/egg/cache_fullrenderer.html'; diff --git a/www/shell/extendedgitgraph_refresh.php b/www/shell/extendedgitgraph_refresh.php index 081d58f..cbf5c01 100644 --- a/www/shell/extendedgitgraph_refresh.php +++ b/www/shell/extendedgitgraph_refresh.php @@ -21,10 +21,18 @@ try { $config['output_file'] = false; $config['output_stdout'] = true; + echo "ENV:\n" . print_r($_ENV, true) . "\n"; + require_once __DIR__ .'/../internals/modules/mikeschergitgraph.php'; $egg = new MikescherGitGraph($config); + if (getenv('EGG_FETCHLIMITCOMMITS')) { + $v = intval(getenv('EGG_FETCHLIMITCOMMITS')); + $egg->setFetchLimitCommits($v); + echo "[*] EGG_FETCHLIMITCOMMITS override detected: $v\n";} + + echo "\n"; echo "================================ Start Update ================================\n"; echo "\n";