[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorRepositoryPushLogQuery 4 extends PhabricatorCursorPagedPolicyAwareQuery { 5 6 private $ids; 7 private $phids; 8 private $repositoryPHIDs; 9 private $pusherPHIDs; 10 private $refTypes; 11 private $newRefs; 12 private $pushEventPHIDs; 13 14 public function withIDs(array $ids) { 15 $this->ids = $ids; 16 return $this; 17 } 18 19 public function withPHIDs(array $phids) { 20 $this->phids = $phids; 21 return $this; 22 } 23 24 public function withRepositoryPHIDs(array $repository_phids) { 25 $this->repositoryPHIDs = $repository_phids; 26 return $this; 27 } 28 29 public function withPusherPHIDs(array $pusher_phids) { 30 $this->pusherPHIDs = $pusher_phids; 31 return $this; 32 } 33 34 public function withRefTypes(array $ref_types) { 35 $this->refTypes = $ref_types; 36 return $this; 37 } 38 39 public function withNewRefs(array $new_refs) { 40 $this->newRefs = $new_refs; 41 return $this; 42 } 43 44 public function withPushEventPHIDs(array $phids) { 45 $this->pushEventPHIDs = $phids; 46 return $this; 47 } 48 49 protected function loadPage() { 50 $table = new PhabricatorRepositoryPushLog(); 51 $conn_r = $table->establishConnection('r'); 52 53 $data = queryfx_all( 54 $conn_r, 55 'SELECT * FROM %T %Q %Q %Q', 56 $table->getTableName(), 57 $this->buildWhereClause($conn_r), 58 $this->buildOrderClause($conn_r), 59 $this->buildLimitClause($conn_r)); 60 61 return $table->loadAllFromArray($data); 62 } 63 64 public function willFilterPage(array $logs) { 65 $event_phids = mpull($logs, 'getPushEventPHID'); 66 $events = id(new PhabricatorObjectQuery()) 67 ->setParentQuery($this) 68 ->setViewer($this->getViewer()) 69 ->withPHIDs($event_phids) 70 ->execute(); 71 $events = mpull($events, null, 'getPHID'); 72 73 foreach ($logs as $key => $log) { 74 $event = idx($events, $log->getPushEventPHID()); 75 if (!$event) { 76 unset($logs[$key]); 77 continue; 78 } 79 $log->attachPushEvent($event); 80 } 81 82 return $logs; 83 } 84 85 private function buildWhereClause(AphrontDatabaseConnection $conn_r) { 86 $where = array(); 87 88 if ($this->ids) { 89 $where[] = qsprintf( 90 $conn_r, 91 'id IN (%Ld)', 92 $this->ids); 93 } 94 95 if ($this->phids) { 96 $where[] = qsprintf( 97 $conn_r, 98 'phid IN (%Ls)', 99 $this->phids); 100 } 101 102 if ($this->repositoryPHIDs) { 103 $where[] = qsprintf( 104 $conn_r, 105 'repositoryPHID IN (%Ls)', 106 $this->repositoryPHIDs); 107 } 108 109 if ($this->pusherPHIDs) { 110 $where[] = qsprintf( 111 $conn_r, 112 'pusherPHID in (%Ls)', 113 $this->pusherPHIDs); 114 } 115 116 if ($this->pushEventPHIDs) { 117 $where[] = qsprintf( 118 $conn_r, 119 'pushEventPHID in (%Ls)', 120 $this->pushEventPHIDs); 121 } 122 123 if ($this->refTypes) { 124 $where[] = qsprintf( 125 $conn_r, 126 'refType IN (%Ls)', 127 $this->refTypes); 128 } 129 130 if ($this->newRefs) { 131 $where[] = qsprintf( 132 $conn_r, 133 'refNew IN (%Ls)', 134 $this->newRefs); 135 } 136 137 $where[] = $this->buildPagingClause($conn_r); 138 139 return $this->formatWhereClause($where); 140 } 141 142 public function getQueryApplicationClass() { 143 return 'PhabricatorDiffusionApplication'; 144 } 145 146 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |