public function fetchIssues($user, $repository) { $sixMonthsAgo = new \DateTime('-6 month'); $sixMonthsAgo = $sixMonthsAgo->format('Y-m-d'); // Pre-filter with labels to fetch as little issues as possible $excludedLabels = $this->getExcludedLabelsSearchString(); $query = "repo:{$user}/{$repository} type:issue created:>{$sixMonthsAgo} {$excludedLabels}"; $paginator = new SearchPager($this->github); try { $results = $paginator->fetchAll($query); } catch (ValidationFailedException $e) { if (strpos($e->getMessage(), 'Validation Failed: Field "q" is invalid') === 0) { throw new RuntimeException('Not Found'); } throw $e; } return array_map(function (array $data) { return Issue::fromArray($data); }, $results); }
/** * @param string $user * @param string $repository * @return Issue[] */ private function fetchIssues($user, $repository) { /** @var \GitHub\Api\Issue $issueApi */ $issueApi = $this->github->api('issue'); $paginator = new ResultPager($this->github); $issues = $paginator->fetchAll($issueApi, 'all', [$user, $repository, ['state' => 'all']]); $issues = array_map(function (array $data) { return Issue::fromArray($data); }, $issues); return $issues; }