3 final class PhabricatorRepositoryPullEventQuery
4 extends PhabricatorCursorPagedPolicyAwareQuery
{
8 private $repositoryPHIDs;
13 public function withIDs(array $ids) {
18 public function withPHIDs(array $phids) {
19 $this->phids
= $phids;
23 public function withRepositoryPHIDs(array $repository_phids) {
24 $this->repositoryPHIDs
= $repository_phids;
28 public function withPullerPHIDs(array $puller_phids) {
29 $this->pullerPHIDs
= $puller_phids;
33 public function withEpochBetween($min, $max) {
34 $this->epochMin
= $min;
35 $this->epochMax
= $max;
39 public function newResultObject() {
40 return new PhabricatorRepositoryPullEvent();
43 protected function willFilterPage(array $events) {
44 // If a pull targets an invalid repository or fails before authenticating,
45 // it may not have an associated repository.
47 $repository_phids = mpull($events, 'getRepositoryPHID');
48 $repository_phids = array_filter($repository_phids);
50 if ($repository_phids) {
51 $repositories = id(new PhabricatorRepositoryQuery())
52 ->setViewer($this->getViewer())
53 ->withPHIDs($repository_phids)
55 $repositories = mpull($repositories, null, 'getPHID');
57 $repositories = array();
60 foreach ($events as $key => $event) {
61 $phid = $event->getRepositoryPHID();
63 $event->attachRepository(null);
67 if (empty($repositories[$phid])) {
69 $this->didRejectResult($event);
73 $event->attachRepository($repositories[$phid]);
79 protected function buildWhereClauseParts(AphrontDatabaseConnection
$conn) {
80 $where = parent
::buildWhereClauseParts($conn);
82 if ($this->ids
!== null) {
89 if ($this->phids
!== null) {
96 if ($this->repositoryPHIDs
!== null) {
99 'repositoryPHID IN (%Ls)',
100 $this->repositoryPHIDs
);
103 if ($this->pullerPHIDs
!== null) {
106 'pullerPHID in (%Ls)',
110 if ($this->epochMin
!== null) {
117 if ($this->epochMax
!== null) {
127 public function getQueryApplicationClass() {
128 return 'PhabricatorDiffusionApplication';