public function executeView() { $pullid = (int) mfwRequest::get('pull_id'); $pull = PullRequestDb::retrieveByPK($pullid); if (!$pull) { return $this->buildErrorPage("pull request no found (id={$pullid})"); } $repo = $this->repolist[$pull->getRepoId()]; $rawpull = Github::getSinglePullRequest($repo->getName(), $pull->getNumber()); $comments = Github::getPullRequestComments($repo->getName(), $pull->getNumber()); $files = Github::getPullRequestFiles($repo->getName(), $pull->getNumber()); $alerts = PullRequestAlertDb::selectByPullRequest($pull); $filters = FilterDb::selectAll(); $alert_filters = array(); foreach ($alerts as $a) { $alert_filters[$a->getFileName()][] = $filters[$a->getFilterId()]; } $params = array('rawpull' => $rawpull, 'comments' => $comments, 'files' => $files, 'pull' => $pull, 'repo' => $repo, 'alert_filters' => $alert_filters); return $this->build($params); }
protected function makeAlertBlock($pull) { static $filterlist = null; if (is_null($filterlist)) { $filterlist = FilterDb::selectAll(); } $repo = $this->repolist[$pull->getRepoId()]; $alerts = $pull->getAllAlerts(); $file_alerts = array(); foreach ($alerts as $a) { $file_alerts[$a->getFileName()][] = $filterlist[$a->getFilterId()]; } $nonfile_alerts = array(); if (isset($file_alerts[''])) { $nonfile_alerts = $file_alerts['']; unset($file_alerts['']); } $files = array(); foreach ($file_alerts as $file => $alerts) { $files[] = array('filename' => $file, 'alerts' => $alerts); } $github_url = "https://github.com/{$this->github_project_owner}/{$repo->getName()}/pull/{$pull->getNumber()}"; return array('pull' => $pull, 'repo' => $repo, 'github_url' => $github_url, 'alerts' => $nonfile_alerts, 'files' => $files); }
} $pulls = json_decode($pulls, true); foreach ($pulls as $p) { if ($p['number'] > $cursor_before) { $cursor = max($p['number'], $cursor); $pulllists[$repo->getId()][$p['number']] = $p; } } $cursorlist[$repo->getId()] = $cursor; } unset($params); unset($pulls); /*---------------------------------------------------------------------------- * filter準備 */ $filters = FilterDb::selectEnable(); $filefilters = $filters->filterForFiles(); $pullfilters = $filters->filterForPulls(); unset($filters); /*---------------------------------------------------------------------------- * pull requestの中身を精査 */ $alterts = array(); $alerted_pulls = array(); foreach ($pulllists as $repo_id => $pulls) { $repo = $repos[$repo_id]; echo "repository: {$repo->getName()}\n"; // number昇順 usort($pulls, function ($a, $b) { return $a['number'] - $b['number']; });