Differential D18968 Diff 45495 src/applications/repository/query/PhabricatorRepositoryPushLogQuery.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/repository/query/PhabricatorRepositoryPushLogQuery.php
| Show All 40 Lines | public function withNewRefs(array $new_refs) { | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function withPushEventPHIDs(array $phids) { | public function withPushEventPHIDs(array $phids) { | ||||
| $this->pushEventPHIDs = $phids; | $this->pushEventPHIDs = $phids; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| protected function loadPage() { | public function newResultObject() { | ||||
| $table = new PhabricatorRepositoryPushLog(); | return new PhabricatorRepositoryPushLog(); | ||||
| $conn_r = $table->establishConnection('r'); | } | ||||
| $data = queryfx_all( | |||||
| $conn_r, | |||||
| 'SELECT * FROM %T %Q %Q %Q', | |||||
| $table->getTableName(), | |||||
| $this->buildWhereClause($conn_r), | |||||
| $this->buildOrderClause($conn_r), | |||||
| $this->buildLimitClause($conn_r)); | |||||
| return $table->loadAllFromArray($data); | protected function loadPage() { | ||||
| return $this->loadStandardPage($this->newResultObject()); | |||||
| } | } | ||||
| protected function willFilterPage(array $logs) { | protected function willFilterPage(array $logs) { | ||||
| $event_phids = mpull($logs, 'getPushEventPHID'); | $event_phids = mpull($logs, 'getPushEventPHID'); | ||||
| $events = id(new PhabricatorObjectQuery()) | $events = id(new PhabricatorObjectQuery()) | ||||
| ->setParentQuery($this) | ->setParentQuery($this) | ||||
| ->setViewer($this->getViewer()) | ->setViewer($this->getViewer()) | ||||
| ->withPHIDs($event_phids) | ->withPHIDs($event_phids) | ||||
| ->execute(); | ->execute(); | ||||
| $events = mpull($events, null, 'getPHID'); | $events = mpull($events, null, 'getPHID'); | ||||
| foreach ($logs as $key => $log) { | foreach ($logs as $key => $log) { | ||||
| $event = idx($events, $log->getPushEventPHID()); | $event = idx($events, $log->getPushEventPHID()); | ||||
| if (!$event) { | if (!$event) { | ||||
| unset($logs[$key]); | unset($logs[$key]); | ||||
| continue; | continue; | ||||
| } | } | ||||
| $log->attachPushEvent($event); | $log->attachPushEvent($event); | ||||
| } | } | ||||
| return $logs; | return $logs; | ||||
| } | } | ||||
| protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { | protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { | ||||
| $where = array(); | $where = parent::buildWhereClauseParts($conn); | ||||
| if ($this->ids) { | if ($this->ids !== null) { | ||||
| $where[] = qsprintf( | $where[] = qsprintf( | ||||
| $conn_r, | $conn, | ||||
| 'id IN (%Ld)', | 'id IN (%Ld)', | ||||
| $this->ids); | $this->ids); | ||||
| } | } | ||||
| if ($this->phids) { | if ($this->phids !== null) { | ||||
| $where[] = qsprintf( | $where[] = qsprintf( | ||||
| $conn_r, | $conn, | ||||
| 'phid IN (%Ls)', | 'phid IN (%Ls)', | ||||
| $this->phids); | $this->phids); | ||||
| } | } | ||||
| if ($this->repositoryPHIDs) { | if ($this->repositoryPHIDs !== null) { | ||||
| $where[] = qsprintf( | $where[] = qsprintf( | ||||
| $conn_r, | $conn, | ||||
| 'repositoryPHID IN (%Ls)', | 'repositoryPHID IN (%Ls)', | ||||
| $this->repositoryPHIDs); | $this->repositoryPHIDs); | ||||
| } | } | ||||
| if ($this->pusherPHIDs) { | if ($this->pusherPHIDs !== null) { | ||||
| $where[] = qsprintf( | $where[] = qsprintf( | ||||
| $conn_r, | $conn, | ||||
| 'pusherPHID in (%Ls)', | 'pusherPHID in (%Ls)', | ||||
| $this->pusherPHIDs); | $this->pusherPHIDs); | ||||
| } | } | ||||
| if ($this->pushEventPHIDs) { | if ($this->pushEventPHIDs !== null) { | ||||
| $where[] = qsprintf( | $where[] = qsprintf( | ||||
| $conn_r, | $conn, | ||||
| 'pushEventPHID in (%Ls)', | 'pushEventPHID in (%Ls)', | ||||
| $this->pushEventPHIDs); | $this->pushEventPHIDs); | ||||
| } | } | ||||
| if ($this->refTypes) { | if ($this->refTypes !== null) { | ||||
| $where[] = qsprintf( | $where[] = qsprintf( | ||||
| $conn_r, | $conn, | ||||
| 'refType IN (%Ls)', | 'refType IN (%Ls)', | ||||
| $this->refTypes); | $this->refTypes); | ||||
| } | } | ||||
| if ($this->newRefs) { | if ($this->newRefs !== null) { | ||||
| $where[] = qsprintf( | $where[] = qsprintf( | ||||
| $conn_r, | $conn, | ||||
| 'refNew IN (%Ls)', | 'refNew IN (%Ls)', | ||||
| $this->newRefs); | $this->newRefs); | ||||
| } | } | ||||
| $where[] = $this->buildPagingClause($conn_r); | return $where; | ||||
| return $this->formatWhereClause($where); | |||||
| } | } | ||||
| public function getQueryApplicationClass() { | public function getQueryApplicationClass() { | ||||
| return 'PhabricatorDiffusionApplication'; | return 'PhabricatorDiffusionApplication'; | ||||
| } | } | ||||
| } | } | ||||