mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-18 19:40:55 +01:00
Support searching for Harbormater build plans by name substring
Summary: Ref T10457. Allow build plans to be queried by name. Test Plan: - Searched for plans by name. - Renamed a plan, searched for new name. {F1133085} Reviewers: chad Reviewed By: chad Maniphest Tasks: T10457 Differential Revision: https://secure.phabricator.com/D15359
This commit is contained in:
parent
2e19b78b8d
commit
f078fd98d7
8 changed files with 79 additions and 6 deletions
|
@ -0,0 +1,7 @@
|
||||||
|
CREATE TABLE {$NAMESPACE}_harbormaster.harbormaster_buildplanname_ngrams (
|
||||||
|
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
objectID INT UNSIGNED NOT NULL,
|
||||||
|
ngram CHAR(3) NOT NULL COLLATE {$COLLATE_TEXT},
|
||||||
|
KEY `key_object` (objectID),
|
||||||
|
KEY `key_ngram` (ngram, objectID)
|
||||||
|
) ENGINE=InnoDB, COLLATE {$COLLATE_TEXT};
|
11
resources/sql/autopatches/20160227.harbormaster.2.plani.php
Normal file
11
resources/sql/autopatches/20160227.harbormaster.2.plani.php
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$table = new HarbormasterBuildPlan();
|
||||||
|
|
||||||
|
foreach (new LiskMigrationIterator($table) as $plan) {
|
||||||
|
PhabricatorSearchWorker::queueDocumentForIndexing(
|
||||||
|
$plan->getPHID(),
|
||||||
|
array(
|
||||||
|
'force' => true,
|
||||||
|
));
|
||||||
|
}
|
|
@ -1055,6 +1055,7 @@ phutil_register_library_map(array(
|
||||||
'HarbormasterBuildPlanDefaultViewCapability' => 'applications/harbormaster/capability/HarbormasterBuildPlanDefaultViewCapability.php',
|
'HarbormasterBuildPlanDefaultViewCapability' => 'applications/harbormaster/capability/HarbormasterBuildPlanDefaultViewCapability.php',
|
||||||
'HarbormasterBuildPlanEditEngine' => 'applications/harbormaster/editor/HarbormasterBuildPlanEditEngine.php',
|
'HarbormasterBuildPlanEditEngine' => 'applications/harbormaster/editor/HarbormasterBuildPlanEditEngine.php',
|
||||||
'HarbormasterBuildPlanEditor' => 'applications/harbormaster/editor/HarbormasterBuildPlanEditor.php',
|
'HarbormasterBuildPlanEditor' => 'applications/harbormaster/editor/HarbormasterBuildPlanEditor.php',
|
||||||
|
'HarbormasterBuildPlanNameNgrams' => 'applications/harbormaster/storage/configuration/HarbormasterBuildPlanNameNgrams.php',
|
||||||
'HarbormasterBuildPlanPHIDType' => 'applications/harbormaster/phid/HarbormasterBuildPlanPHIDType.php',
|
'HarbormasterBuildPlanPHIDType' => 'applications/harbormaster/phid/HarbormasterBuildPlanPHIDType.php',
|
||||||
'HarbormasterBuildPlanQuery' => 'applications/harbormaster/query/HarbormasterBuildPlanQuery.php',
|
'HarbormasterBuildPlanQuery' => 'applications/harbormaster/query/HarbormasterBuildPlanQuery.php',
|
||||||
'HarbormasterBuildPlanSearchEngine' => 'applications/harbormaster/query/HarbormasterBuildPlanSearchEngine.php',
|
'HarbormasterBuildPlanSearchEngine' => 'applications/harbormaster/query/HarbormasterBuildPlanSearchEngine.php',
|
||||||
|
@ -5199,12 +5200,14 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorApplicationTransactionInterface',
|
'PhabricatorApplicationTransactionInterface',
|
||||||
'PhabricatorPolicyInterface',
|
'PhabricatorPolicyInterface',
|
||||||
'PhabricatorSubscribableInterface',
|
'PhabricatorSubscribableInterface',
|
||||||
|
'PhabricatorNgramsInterface',
|
||||||
),
|
),
|
||||||
'HarbormasterBuildPlanDatasource' => 'PhabricatorTypeaheadDatasource',
|
'HarbormasterBuildPlanDatasource' => 'PhabricatorTypeaheadDatasource',
|
||||||
'HarbormasterBuildPlanDefaultEditCapability' => 'PhabricatorPolicyCapability',
|
'HarbormasterBuildPlanDefaultEditCapability' => 'PhabricatorPolicyCapability',
|
||||||
'HarbormasterBuildPlanDefaultViewCapability' => 'PhabricatorPolicyCapability',
|
'HarbormasterBuildPlanDefaultViewCapability' => 'PhabricatorPolicyCapability',
|
||||||
'HarbormasterBuildPlanEditEngine' => 'PhabricatorEditEngine',
|
'HarbormasterBuildPlanEditEngine' => 'PhabricatorEditEngine',
|
||||||
'HarbormasterBuildPlanEditor' => 'PhabricatorApplicationTransactionEditor',
|
'HarbormasterBuildPlanEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||||
|
'HarbormasterBuildPlanNameNgrams' => 'PhabricatorSearchNgrams',
|
||||||
'HarbormasterBuildPlanPHIDType' => 'PhabricatorPHIDType',
|
'HarbormasterBuildPlanPHIDType' => 'PhabricatorPHIDType',
|
||||||
'HarbormasterBuildPlanQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
'HarbormasterBuildPlanQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||||
'HarbormasterBuildPlanSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
'HarbormasterBuildPlanSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||||
|
|
|
@ -11,6 +11,10 @@ final class HarbormasterBuildPlanEditor
|
||||||
return pht('Harbormaster Build Plans');
|
return pht('Harbormaster Build Plans');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function supportsSearch() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public function getTransactionTypes() {
|
public function getTransactionTypes() {
|
||||||
$types = parent::getTransactionTypes();
|
$types = parent::getTransactionTypes();
|
||||||
$types[] = HarbormasterBuildPlanTransaction::TYPE_NAME;
|
$types[] = HarbormasterBuildPlanTransaction::TYPE_NAME;
|
||||||
|
|
|
@ -35,6 +35,12 @@ final class HarbormasterBuildPlanQuery
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function withNameNgrams($ngrams) {
|
||||||
|
return $this->withNgramsConstraint(
|
||||||
|
new HarbormasterBuildPlanNameNgrams(),
|
||||||
|
$ngrams);
|
||||||
|
}
|
||||||
|
|
||||||
public function needBuildSteps($need) {
|
public function needBuildSteps($need) {
|
||||||
$this->needBuildSteps = $need;
|
$this->needBuildSteps = $need;
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -74,41 +80,45 @@ final class HarbormasterBuildPlanQuery
|
||||||
if ($this->ids !== null) {
|
if ($this->ids !== null) {
|
||||||
$where[] = qsprintf(
|
$where[] = qsprintf(
|
||||||
$conn,
|
$conn,
|
||||||
'id IN (%Ld)',
|
'plan.id IN (%Ld)',
|
||||||
$this->ids);
|
$this->ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->phids !== null) {
|
if ($this->phids !== null) {
|
||||||
$where[] = qsprintf(
|
$where[] = qsprintf(
|
||||||
$conn,
|
$conn,
|
||||||
'phid IN (%Ls)',
|
'plan.phid IN (%Ls)',
|
||||||
$this->phids);
|
$this->phids);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->statuses !== null) {
|
if ($this->statuses !== null) {
|
||||||
$where[] = qsprintf(
|
$where[] = qsprintf(
|
||||||
$conn,
|
$conn,
|
||||||
'planStatus IN (%Ls)',
|
'plan.planStatus IN (%Ls)',
|
||||||
$this->statuses);
|
$this->statuses);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen($this->datasourceQuery)) {
|
if (strlen($this->datasourceQuery)) {
|
||||||
$where[] = qsprintf(
|
$where[] = qsprintf(
|
||||||
$conn,
|
$conn,
|
||||||
'name LIKE %>',
|
'plan.name LIKE %>',
|
||||||
$this->datasourceQuery);
|
$this->datasourceQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->planAutoKeys !== null) {
|
if ($this->planAutoKeys !== null) {
|
||||||
$where[] = qsprintf(
|
$where[] = qsprintf(
|
||||||
$conn,
|
$conn,
|
||||||
'planAutoKey IN (%Ls)',
|
'plan.planAutoKey IN (%Ls)',
|
||||||
$this->planAutoKeys);
|
$this->planAutoKeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $where;
|
return $where;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getPrimaryTableAlias() {
|
||||||
|
return 'plan';
|
||||||
|
}
|
||||||
|
|
||||||
public function getQueryApplicationClass() {
|
public function getQueryApplicationClass() {
|
||||||
return 'PhabricatorHarbormasterApplication';
|
return 'PhabricatorHarbormasterApplication';
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,10 @@ final class HarbormasterBuildPlanSearchEngine
|
||||||
|
|
||||||
protected function buildCustomSearchFields() {
|
protected function buildCustomSearchFields() {
|
||||||
return array(
|
return array(
|
||||||
|
id(new PhabricatorSearchTextField())
|
||||||
|
->setLabel(pht('Name Contains'))
|
||||||
|
->setKey('match')
|
||||||
|
->setDescription(pht('Search for namespaces by name substring.')),
|
||||||
id(new PhabricatorSearchCheckboxesField())
|
id(new PhabricatorSearchCheckboxesField())
|
||||||
->setLabel(pht('Status'))
|
->setLabel(pht('Status'))
|
||||||
->setKey('status')
|
->setKey('status')
|
||||||
|
@ -32,6 +36,10 @@ final class HarbormasterBuildPlanSearchEngine
|
||||||
protected function buildQueryFromParameters(array $map) {
|
protected function buildQueryFromParameters(array $map) {
|
||||||
$query = $this->newQuery();
|
$query = $this->newQuery();
|
||||||
|
|
||||||
|
if ($map['match'] !== null) {
|
||||||
|
$query->withNameNgrams($map['match']);
|
||||||
|
}
|
||||||
|
|
||||||
if ($map['status']) {
|
if ($map['status']) {
|
||||||
$query->withStatuses($map['status']);
|
$query->withStatuses($map['status']);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,8 @@ final class HarbormasterBuildPlan extends HarbormasterDAO
|
||||||
implements
|
implements
|
||||||
PhabricatorApplicationTransactionInterface,
|
PhabricatorApplicationTransactionInterface,
|
||||||
PhabricatorPolicyInterface,
|
PhabricatorPolicyInterface,
|
||||||
PhabricatorSubscribableInterface {
|
PhabricatorSubscribableInterface,
|
||||||
|
PhabricatorNgramsInterface {
|
||||||
|
|
||||||
protected $name;
|
protected $name;
|
||||||
protected $planStatus;
|
protected $planStatus;
|
||||||
|
@ -198,4 +199,15 @@ final class HarbormasterBuildPlan extends HarbormasterDAO
|
||||||
return $messages;
|
return $messages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* -( PhabricatorNgramInterface )------------------------------------------ */
|
||||||
|
|
||||||
|
|
||||||
|
public function newNgrams() {
|
||||||
|
return array(
|
||||||
|
id(new HarbormasterBuildPlanNameNgrams())
|
||||||
|
->setValue($this->getName()),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class HarbormasterBuildPlanNameNgrams
|
||||||
|
extends PhabricatorSearchNgrams {
|
||||||
|
|
||||||
|
public function getNgramKey() {
|
||||||
|
return 'buildplanname';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getColumnName() {
|
||||||
|
return 'name';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getApplicationName() {
|
||||||
|
return 'harbormaster';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue