diff --git a/controllers/dashboard.php b/controllers/dashboard.php index c75a1ea365548e793183ef0bc6264a0f6497b33f..3e345832a8fa809619615e5fdc9be69874d5bc95 100644 --- a/controllers/dashboard.php +++ b/controllers/dashboard.php @@ -126,7 +126,7 @@ final class DashboardController extends TracToGitlab\GitlabController foreach (explode(',', $this->getSelected('types')) as $type) { $issues = array_merge( $issues, - $this->result_pager->fetchAll( + $this->fetchAll( $this->gitlab->issues(), 'all', [ @@ -157,7 +157,7 @@ final class DashboardController extends TracToGitlab\GitlabController private function getMilestones() { return $this->cached('milestones', function () { - $milestones = $this->result_pager->fetchAll( + $milestones = $this->fetchAll( $this->gitlab->milestones(), 'all', [Config::get()->TRAC2GITLAB_GITLAB_PROJECT_ID] diff --git a/controllers/labels.php b/controllers/labels.php index 8a9a52cac7f3f64a767432198e7cc0eff968f36d..aa881d038cbe33448b926233a806c7a063cf532a 100644 --- a/controllers/labels.php +++ b/controllers/labels.php @@ -12,11 +12,17 @@ final class LabelsController extends \TracToGitlab\GitlabController public function index_action() { $this->labels = $this->cached('labels', fn() => $this->fetchLabels()); + + Sidebar::get()->addWidget(new TemplateWidget( + _('Stand der Daten'), + $this->get_template_factory()->open('sidebar'), + ['time' => $this->getCachedDate('labels')] + )); } private function fetchLabels(): array { - $labels = $this->result_pager->fetchAll( + $labels = $this->fetchAll( $this->gitlab->projects(), 'labels', [ @@ -25,9 +31,7 @@ final class LabelsController extends \TracToGitlab\GitlabController ] ); - usort($labels, function (array $a, array $b) { - return strnatcasecmp($a['name'], $b['name']); - }); + usort($labels, fn(array $a, array $b) => strnatcasecmp($a['name'], $b['name'])); return $labels; } diff --git a/controllers/merge.php b/controllers/merge.php index d2b6046a4da627882b0cd6573e00859b26da34d6..03634a0cf9b1af4fd5f0a15fee14be33c60ddfd2 100644 --- a/controllers/merge.php +++ b/controllers/merge.php @@ -22,7 +22,7 @@ final class MergeController extends TracToGitlab\GitlabController private function fetchIssues(): array { - $issues = $this->result_pager->fetchAll( + $issues = $this->fetchAll( $this->gitlab->issues(), 'all', [ diff --git a/controllers/mergerequests.php b/controllers/mergerequests.php index 66985de9528af5d99d919b1dfaf5f06cda8ad901..d70c8c928e4cfc4723b4a9fe1e0a8978e0a7440e 100644 --- a/controllers/mergerequests.php +++ b/controllers/mergerequests.php @@ -22,7 +22,7 @@ final class MergerequestsController extends TracToGitlab\GitlabController private function fetchMergeRequests(): array { - $mrs = $this->result_pager->fetchAll( + $mrs = $this->fetchAll( $this->gitlab->mergeRequests(), 'all', [ diff --git a/lib/GitlabController.php b/lib/GitlabController.php index a1275d71d821e487a47d447206f0b3590c0a0fde..db12e19dec126e58be14e52b42ae8968b1e4c207 100644 --- a/lib/GitlabController.php +++ b/lib/GitlabController.php @@ -3,6 +3,7 @@ namespace TracToGitlab; use Config; use Gitlab; +use Gitlab\Api\AbstractApi; use TracToGitlab\Traits\Cached; abstract class GitlabController extends Controller @@ -11,7 +12,6 @@ abstract class GitlabController extends Controller protected int $gitlab_project_id; protected Gitlab\Client $gitlab; - protected Gitlab\ResultPager $result_pager; public function before_filter(&$action, &$args) { @@ -21,6 +21,11 @@ abstract class GitlabController extends Controller $this->gitlab_project_id = Config::get()->TRAC2GITLAB_GITLAB_PROJECT_ID; $this->gitlab = app(Gitlab\Client::class); - $this->result_pager = app(Gitlab\ResultPager::class); + } + + protected function fetchAll(AbstractApi $api, string $method, array $parameters = []): array + { + $pager = new \Gitlab\ResultPager($this->gitlab, 100); + return $pager->fetchAll($api, $method, $parameters); } } diff --git a/lib/Plugin.php b/lib/Plugin.php index 8badf746cdd57a75498c331318225d68078bfbfa..7df73c2318e26cac6df4cbcba26d6ece12ba6927 100644 --- a/lib/Plugin.php +++ b/lib/Plugin.php @@ -3,7 +3,7 @@ namespace TracToGitlab; use Config; use Gitlab; -use Pimple; +use Parsedown; use Psr\Http\Client\ClientInterface; use Studip\DIContainer; @@ -18,9 +18,6 @@ abstract class Plugin extends \StudIPPlugin $container->set(ClientInterface::class, function () { return new \GuzzleHttp\Client(); }); - $container->set(TracLookup::class, function () { - return new TracLookup(Config::get()->TRAC2GITLAB_TRAC_URL); - }); $container->set(Gitlab\Client::class, function (ClientInterface $client) { $builder = new Gitlab\HttpClient\Builder( $client, @@ -34,9 +31,6 @@ abstract class Plugin extends \StudIPPlugin $client->authenticate(Config::get()->TRAC2GITLAB_GITLAB_TOKEN, Gitlab\Client::AUTH_HTTP_TOKEN); return $client; }); - $container->set(Gitlab\ResultPager::class, function (Gitlab\Client $client) { - return new Gitlab\ResultPager($client); - }); $container->set(Parsedown::class, function () { $parsedown = new Parsedown(); $parsedown->setSafeMode(true);