Changeset View
Changeset View
Standalone View
Standalone View
src/applications/pholio/query/PholioMockQuery.php
Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | final class PholioMockQuery | ||||
} | } | ||||
protected function loadPage() { | protected function loadPage() { | ||||
$table = new PholioMock(); | $table = new PholioMock(); | ||||
$conn_r = $table->establishConnection('r'); | $conn_r = $table->establishConnection('r'); | ||||
$data = queryfx_all( | $data = queryfx_all( | ||||
$conn_r, | $conn_r, | ||||
'SELECT * FROM %T %Q %Q %Q', | '%Q FROM %T mock %Q %Q %Q %Q %Q %Q', | ||||
$this->buildSelectClause($conn_r), | |||||
$table->getTableName(), | $table->getTableName(), | ||||
$this->buildJoinClause($conn_r), | |||||
$this->buildWhereClause($conn_r), | $this->buildWhereClause($conn_r), | ||||
$this->buildGroupClause($conn_r), | |||||
$this->buildOrderClause($conn_r), | $this->buildOrderClause($conn_r), | ||||
$this->buildHavingClause($conn_r), | |||||
$this->buildLimitClause($conn_r)); | $this->buildLimitClause($conn_r)); | ||||
$mocks = $table->loadAllFromArray($data); | $mocks = $table->loadAllFromArray($data); | ||||
if ($mocks && $this->needImages) { | if ($mocks && $this->needImages) { | ||||
self::loadImages($this->getViewer(), $mocks, $this->needInlineComments); | self::loadImages($this->getViewer(), $mocks, $this->needInlineComments); | ||||
} | } | ||||
if ($mocks && $this->needCoverFiles) { | if ($mocks && $this->needCoverFiles) { | ||||
$this->loadCoverFiles($mocks); | $this->loadCoverFiles($mocks); | ||||
} | } | ||||
if ($mocks && $this->needTokenCounts) { | if ($mocks && $this->needTokenCounts) { | ||||
$this->loadTokenCounts($mocks); | $this->loadTokenCounts($mocks); | ||||
} | } | ||||
return $mocks; | return $mocks; | ||||
} | } | ||||
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { | protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { | ||||
$where = array(); | $where = array(); | ||||
$where[] = $this->buildPagingClause($conn_r); | $where[] = $this->buildWhereClauseParts($conn_r); | ||||
if ($this->ids) { | if ($this->ids !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn_r, | $conn_r, | ||||
'id IN (%Ld)', | 'mock.id IN (%Ld)', | ||||
$this->ids); | $this->ids); | ||||
} | } | ||||
if ($this->phids) { | if ($this->phids !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn_r, | $conn_r, | ||||
'phid IN (%Ls)', | 'mock.phid IN (%Ls)', | ||||
$this->phids); | $this->phids); | ||||
} | } | ||||
if ($this->authorPHIDs) { | if ($this->authorPHIDs !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn_r, | $conn_r, | ||||
'authorPHID in (%Ls)', | 'mock.authorPHID in (%Ls)', | ||||
$this->authorPHIDs); | $this->authorPHIDs); | ||||
} | } | ||||
if ($this->statuses) { | if ($this->statuses !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn_r, | $conn_r, | ||||
'status IN (%Ls)', | 'mock.status IN (%Ls)', | ||||
$this->statuses); | $this->statuses); | ||||
} | } | ||||
return $this->formatWhereClause($where); | return $this->formatWhereClause($where); | ||||
} | } | ||||
public static function loadImages( | public static function loadImages( | ||||
PhabricatorUser $viewer, | PhabricatorUser $viewer, | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | foreach ($mocks as $mock) { | ||||
$mock->attachTokenCount(idx($counts, $mock->getPHID(), 0)); | $mock->attachTokenCount(idx($counts, $mock->getPHID(), 0)); | ||||
} | } | ||||
} | } | ||||
public function getQueryApplicationClass() { | public function getQueryApplicationClass() { | ||||
return 'PhabricatorPholioApplication'; | return 'PhabricatorPholioApplication'; | ||||
} | } | ||||
public function getPrimaryTableAlias() { | |||||
return 'mock'; | |||||
} | |||||
} | } |