Changeset View
Changeset View
Standalone View
Standalone View
src/applications/almanac/query/AlmanacServiceQuery.php
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | public function withNamePrefix($prefix) { | ||||
return $this; | return $this; | ||||
} | } | ||||
public function withNameSuffix($suffix) { | public function withNameSuffix($suffix) { | ||||
$this->nameSuffix = $suffix; | $this->nameSuffix = $suffix; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function withNameNgrams($ngrams) { | |||||
return $this->withNgramsConstraint( | |||||
new AlmanacServiceNameNgrams(), | |||||
$ngrams); | |||||
} | |||||
public function needBindings($need_bindings) { | public function needBindings($need_bindings) { | ||||
$this->needBindings = $need_bindings; | $this->needBindings = $need_bindings; | ||||
return $this; | return $this; | ||||
} | } | ||||
protected function loadPage() { | protected function loadPage() { | ||||
return $this->loadStandardPage(new AlmanacService()); | return $this->loadStandardPage(new AlmanacService()); | ||||
} | } | ||||
protected function buildJoinClauseParts(AphrontDatabaseConnection $conn) { | protected function buildJoinClauseParts(AphrontDatabaseConnection $conn) { | ||||
$joins = parent::buildJoinClauseParts($conn); | $joins = parent::buildJoinClauseParts($conn); | ||||
if ($this->devicePHIDs !== null) { | if ($this->shouldJoinBindingTable()) { | ||||
$joins[] = qsprintf( | $joins[] = qsprintf( | ||||
$conn, | $conn, | ||||
'JOIN %T binding ON service.phid = binding.servicePHID', | 'JOIN %T binding ON service.phid = binding.servicePHID', | ||||
id(new AlmanacBinding())->getTableName()); | id(new AlmanacBinding())->getTableName()); | ||||
} | } | ||||
return $joins; | return $joins; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | if ($this->needBindings) { | ||||
$service_bindings = idx($bindings, $service->getPHID(), array()); | $service_bindings = idx($bindings, $service->getPHID(), array()); | ||||
$service->attachBindings($service_bindings); | $service->attachBindings($service_bindings); | ||||
} | } | ||||
} | } | ||||
return parent::didFilterPage($services); | return parent::didFilterPage($services); | ||||
} | } | ||||
private function shouldJoinBindingTable() { | |||||
return ($this->devicePHIDs !== null); | |||||
} | |||||
protected function shouldGroupQueryResultRows() { | |||||
if ($this->shouldJoinBindingTable()) { | |||||
return true; | |||||
} | |||||
return parent::shouldGroupQueryResultRows(); | |||||
} | |||||
protected function getPrimaryTableAlias() { | protected function getPrimaryTableAlias() { | ||||
return 'service'; | return 'service'; | ||||
} | } | ||||
public function getOrderableColumns() { | public function getOrderableColumns() { | ||||
return parent::getOrderableColumns() + array( | return parent::getOrderableColumns() + array( | ||||
'name' => array( | 'name' => array( | ||||
'table' => $this->getPrimaryTableAlias(), | 'table' => $this->getPrimaryTableAlias(), | ||||
Show All 26 Lines |