Example #1
0
 public function executeIndex()
 {
     $page = (int) mfwRequest::get('page', 1);
     $count = PullRequestDb::totalCount();
     $page_max = floor(($count - 1) / self::ITEMS_PER_PAGE) + 1;
     $page = max(1, min($page, $page_max));
     $offset = ($page - 1) * self::ITEMS_PER_PAGE;
     $pulls = PullRequestDb::selectForPager($offset, self::ITEMS_PER_PAGE);
     $alerts = array();
     foreach ($pulls as $p) {
         $alerts[] = $this->makeAlertBlock($p);
     }
     $params = array('alerts' => $alerts, 'page' => $page, 'page_max' => $page_max);
     return $this->build($params);
 }
Example #2
0
 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);
 }