3 final class PhabricatorRepositoryPushEventQuery
4 extends PhabricatorCursorPagedPolicyAwareQuery
{
8 private $repositoryPHIDs;
12 public function withIDs(array $ids) {
17 public function withPHIDs(array $phids) {
18 $this->phids
= $phids;
22 public function withRepositoryPHIDs(array $repository_phids) {
23 $this->repositoryPHIDs
= $repository_phids;
27 public function withPusherPHIDs(array $pusher_phids) {
28 $this->pusherPHIDs
= $pusher_phids;
32 public function needLogs($need_logs) {
33 $this->needLogs
= $need_logs;
37 public function newResultObject() {
38 return new PhabricatorRepositoryPushEvent();
41 protected function willFilterPage(array $events) {
42 $repository_phids = mpull($events, 'getRepositoryPHID');
43 $repositories = id(new PhabricatorRepositoryQuery())
44 ->setViewer($this->getViewer())
45 ->withPHIDs($repository_phids)
47 $repositories = mpull($repositories, null, 'getPHID');
49 foreach ($events as $key => $event) {
50 $phid = $event->getRepositoryPHID();
51 if (empty($repositories[$phid])) {
55 $event->attachRepository($repositories[$phid]);
61 protected function didFilterPage(array $events) {
62 $phids = mpull($events, 'getPHID');
64 if ($this->needLogs
) {
65 $logs = id(new PhabricatorRepositoryPushLogQuery())
66 ->setParentQuery($this)
67 ->setViewer($this->getViewer())
68 ->withPushEventPHIDs($phids)
70 $logs = mgroup($logs, 'getPushEventPHID');
71 foreach ($events as $key => $event) {
72 $event_logs = idx($logs, $event->getPHID(), array());
73 $event->attachLogs($event_logs);
80 protected function buildWhereClauseParts(AphrontDatabaseConnection
$conn) {
81 $where = parent
::buildWhereClauseParts($conn);
83 if ($this->ids
!== null) {
90 if ($this->phids
!== null) {
97 if ($this->repositoryPHIDs
!== null) {
100 'repositoryPHID IN (%Ls)',
101 $this->repositoryPHIDs
);
104 if ($this->pusherPHIDs
!== null) {
107 'pusherPHID in (%Ls)',
114 public function getQueryApplicationClass() {
115 return 'PhabricatorDiffusionApplication';