3 final class HeraldTranscriptQuery
4 extends PhabricatorCursorPagedPolicyAwareQuery
{
9 private $needPartialRecords;
11 public function withIDs(array $ids) {
16 public function withPHIDs(array $phids) {
17 $this->phids
= $phids;
21 public function withObjectPHIDs(array $phids) {
22 $this->objectPHIDs
= $phids;
26 public function needPartialRecords($need_partial) {
27 $this->needPartialRecords
= $need_partial;
31 protected function loadPage() {
32 $transcript = new HeraldTranscript();
33 $conn = $transcript->establishConnection('r');
35 // NOTE: Transcripts include a potentially enormous amount of serialized
36 // data, so we're loading only some of the fields here if the caller asked
37 // for partial records.
39 if ($this->needPartialRecords
) {
49 $fields = qsprintf($conn, '%LC', $fields);
51 $fields = qsprintf($conn, '*');
56 'SELECT %Q FROM %T t %Q %Q %Q',
58 $transcript->getTableName(),
59 $this->buildWhereClause($conn),
60 $this->buildOrderClause($conn),
61 $this->buildLimitClause($conn));
63 $transcripts = $transcript->loadAllFromArray($rows);
65 if ($this->needPartialRecords
) {
66 // Make sure nothing tries to write these; they aren't complete.
67 foreach ($transcripts as $transcript) {
68 $transcript->makeEphemeral();
75 protected function willFilterPage(array $transcripts) {
76 $phids = mpull($transcripts, 'getObjectPHID');
78 $objects = id(new PhabricatorObjectQuery())
79 ->setViewer($this->getViewer())
83 foreach ($transcripts as $key => $transcript) {
84 $object_phid = $transcript->getObjectPHID();
87 $transcript->attachObject(null);
91 $object = idx($objects, $object_phid);
93 $this->didRejectResult($transcript);
94 unset($transcripts[$key]);
97 $transcript->attachObject($object);
103 protected function buildWhereClause(AphrontDatabaseConnection
$conn) {
120 if ($this->objectPHIDs
) {
123 'objectPHID in (%Ls)',
127 $where[] = $this->buildPagingClause($conn);
129 return $this->formatWhereClause($conn, $where);
132 public function getQueryApplicationClass() {
133 return 'PhabricatorHeraldApplication';