Пример #1
0
 public function execute()
 {
     $table = new PhabricatorRepositoryAuditRequest();
     $conn_r = $table->establishConnection('r');
     $joins = $this->buildJoinClause($conn_r);
     $where = $this->buildWhereClause($conn_r);
     $order = $this->buildOrderClause($conn_r);
     $limit = $this->buildLimitClause($conn_r);
     $data = queryfx_all($conn_r, 'SELECT req.* FROM %T req %Q %Q %Q %Q', $table->getTableName(), $joins, $where, $order, $limit);
     $audits = $table->loadAllFromArray($data);
     if ($this->needCommits || $this->needCommitData) {
         $phids = mpull($audits, 'getCommitPHID', 'getCommitPHID');
         if ($phids) {
             $cquery = new PhabricatorAuditCommitQuery();
             $cquery->needCommitData($this->needCommitData);
             $cquery->withCommitPHIDs(array_keys($phids));
             $commits = $cquery->execute();
         } else {
             $commits = array();
         }
         $this->commits = $commits;
     }
     return $audits;
 }
 public function buildCommitPanel()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $phids = array($user->getPHID());
     $query = new PhabricatorAuditCommitQuery();
     $query->withAuthorPHIDs($phids);
     $query->withStatus(PhabricatorAuditQuery::STATUS_OPEN);
     $query->needCommitData(true);
     $query->setLimit(10);
     $commits = $query->execute();
     if (!$commits) {
         return $this->renderMinipanel('No Problem Commits', 'No one has raised concerns with your commits.');
     }
     $view = new PhabricatorAuditCommitListView();
     $view->setCommits($commits);
     $view->setUser($user);
     $phids = $view->getRequiredHandlePHIDs();
     $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
     $view->setHandles($handles);
     $panel = new AphrontPanelView();
     $panel->setHeader('Problem Commits');
     $panel->setCaption('Commits which auditors have raised concerns about.');
     $panel->appendChild($view);
     $panel->addButton(phutil_render_tag('a', array('href' => '/audit/', 'class' => 'button grey'), "View Problem Commits »"));
     return $panel;
 }
 private function buildCommitView(PhabricatorObjectHandle $handle = null)
 {
     $request = $this->getRequest();
     $query = new PhabricatorAuditCommitQuery();
     $query->needCommitData(true);
     $use_pager = $this->filter != 'active';
     if ($use_pager) {
         $pager = new AphrontPagerView();
         $pager->setURI($request->getRequestURI(), 'offset');
         $pager->setOffset($request->getInt('offset'));
         $query->setOffset($pager->getOffset());
         $query->setLimit($pager->getPageSize() + 1);
     }
     switch ($this->filter) {
         case 'active':
         case 'author':
             $query->withAuthorPHIDs(array($handle->getPHID()));
             break;
         case 'packagecommits':
             $query->withPackagePHIDs(array($handle->getPHID()));
             break;
     }
     switch ($this->filter) {
         case 'active':
             $query->withStatus(PhabricatorAuditQuery::STATUS_OPEN);
             break;
         case 'author':
         case 'packagecommits':
             switch ($this->filterStatus) {
                 case 'open':
                     $query->withStatus(PhabricatorAuditQuery::STATUS_OPEN);
                     break;
             }
             break;
     }
     if ($handle) {
         $handle_name = phutil_escape_html($handle->getName());
     } else {
         $handle_name = null;
     }
     switch ($this->filter) {
         case 'active':
             $header = 'Problem Commits';
             $nodata = 'None of your commits have open concerns.';
             break;
         case 'author':
             $header = "Commits by {$handle_name}";
             $nodata = "No matching commits by {$handle_name}.";
             break;
         case 'commits':
             $header = "Commits";
             $nodata = "No matching commits.";
             break;
         case 'packagecommits':
             $header = "Commits in Package '{$handle_name}'";
             $nodata = "No matching commits in package '{$handle_name}'.";
             break;
     }
     $commits = $query->execute();
     if ($use_pager) {
         $commits = $pager->sliceResults($commits);
     }
     $view = new PhabricatorAuditCommitListView();
     $view->setUser($request->getUser());
     $view->setCommits($commits);
     $view->setNoDataString($nodata);
     $phids = $view->getRequiredHandlePHIDs();
     $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
     $view->setHandles($handles);
     $panel = new AphrontPanelView();
     $panel->setHeader($header);
     $panel->appendChild($view);
     if ($use_pager) {
         $panel->appendChild($pager);
     }
     return $panel;
 }