Page MenuHomePhabricator

D15359.id37036.diff
No OneTemporary

D15359.id37036.diff

diff --git a/resources/sql/autopatches/20160227.harbormaster.1.plann.sql b/resources/sql/autopatches/20160227.harbormaster.1.plann.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20160227.harbormaster.1.plann.sql
@@ -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};
diff --git a/resources/sql/autopatches/20160227.harbormaster.2.plani.php b/resources/sql/autopatches/20160227.harbormaster.2.plani.php
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20160227.harbormaster.2.plani.php
@@ -0,0 +1,11 @@
+<?php
+
+$table = new HarbormasterBuildPlan();
+
+foreach (new LiskMigrationIterator($table) as $plan) {
+ PhabricatorSearchWorker::queueDocumentForIndexing(
+ $plan->getPHID(),
+ array(
+ 'force' => true,
+ ));
+}
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -1055,6 +1055,7 @@
'HarbormasterBuildPlanDefaultViewCapability' => 'applications/harbormaster/capability/HarbormasterBuildPlanDefaultViewCapability.php',
'HarbormasterBuildPlanEditEngine' => 'applications/harbormaster/editor/HarbormasterBuildPlanEditEngine.php',
'HarbormasterBuildPlanEditor' => 'applications/harbormaster/editor/HarbormasterBuildPlanEditor.php',
+ 'HarbormasterBuildPlanNameNgrams' => 'applications/harbormaster/storage/configuration/HarbormasterBuildPlanNameNgrams.php',
'HarbormasterBuildPlanPHIDType' => 'applications/harbormaster/phid/HarbormasterBuildPlanPHIDType.php',
'HarbormasterBuildPlanQuery' => 'applications/harbormaster/query/HarbormasterBuildPlanQuery.php',
'HarbormasterBuildPlanSearchEngine' => 'applications/harbormaster/query/HarbormasterBuildPlanSearchEngine.php',
@@ -5199,12 +5200,14 @@
'PhabricatorApplicationTransactionInterface',
'PhabricatorPolicyInterface',
'PhabricatorSubscribableInterface',
+ 'PhabricatorNgramsInterface',
),
'HarbormasterBuildPlanDatasource' => 'PhabricatorTypeaheadDatasource',
'HarbormasterBuildPlanDefaultEditCapability' => 'PhabricatorPolicyCapability',
'HarbormasterBuildPlanDefaultViewCapability' => 'PhabricatorPolicyCapability',
'HarbormasterBuildPlanEditEngine' => 'PhabricatorEditEngine',
'HarbormasterBuildPlanEditor' => 'PhabricatorApplicationTransactionEditor',
+ 'HarbormasterBuildPlanNameNgrams' => 'PhabricatorSearchNgrams',
'HarbormasterBuildPlanPHIDType' => 'PhabricatorPHIDType',
'HarbormasterBuildPlanQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'HarbormasterBuildPlanSearchEngine' => 'PhabricatorApplicationSearchEngine',
diff --git a/src/applications/harbormaster/editor/HarbormasterBuildPlanEditor.php b/src/applications/harbormaster/editor/HarbormasterBuildPlanEditor.php
--- a/src/applications/harbormaster/editor/HarbormasterBuildPlanEditor.php
+++ b/src/applications/harbormaster/editor/HarbormasterBuildPlanEditor.php
@@ -11,6 +11,10 @@
return pht('Harbormaster Build Plans');
}
+ protected function supportsSearch() {
+ return true;
+ }
+
public function getTransactionTypes() {
$types = parent::getTransactionTypes();
$types[] = HarbormasterBuildPlanTransaction::TYPE_NAME;
diff --git a/src/applications/harbormaster/query/HarbormasterBuildPlanQuery.php b/src/applications/harbormaster/query/HarbormasterBuildPlanQuery.php
--- a/src/applications/harbormaster/query/HarbormasterBuildPlanQuery.php
+++ b/src/applications/harbormaster/query/HarbormasterBuildPlanQuery.php
@@ -35,6 +35,12 @@
return $this;
}
+ public function withNameNgrams($ngrams) {
+ return $this->withNgramsConstraint(
+ new HarbormasterBuildPlanNameNgrams(),
+ $ngrams);
+ }
+
public function needBuildSteps($need) {
$this->needBuildSteps = $need;
return $this;
@@ -74,41 +80,45 @@
if ($this->ids !== null) {
$where[] = qsprintf(
$conn,
- 'id IN (%Ld)',
+ 'plan.id IN (%Ld)',
$this->ids);
}
if ($this->phids !== null) {
$where[] = qsprintf(
$conn,
- 'phid IN (%Ls)',
+ 'plan.phid IN (%Ls)',
$this->phids);
}
if ($this->statuses !== null) {
$where[] = qsprintf(
$conn,
- 'planStatus IN (%Ls)',
+ 'plan.planStatus IN (%Ls)',
$this->statuses);
}
if (strlen($this->datasourceQuery)) {
$where[] = qsprintf(
$conn,
- 'name LIKE %>',
+ 'plan.name LIKE %>',
$this->datasourceQuery);
}
if ($this->planAutoKeys !== null) {
$where[] = qsprintf(
$conn,
- 'planAutoKey IN (%Ls)',
+ 'plan.planAutoKey IN (%Ls)',
$this->planAutoKeys);
}
return $where;
}
+ protected function getPrimaryTableAlias() {
+ return 'plan';
+ }
+
public function getQueryApplicationClass() {
return 'PhabricatorHarbormasterApplication';
}
diff --git a/src/applications/harbormaster/query/HarbormasterBuildPlanSearchEngine.php b/src/applications/harbormaster/query/HarbormasterBuildPlanSearchEngine.php
--- a/src/applications/harbormaster/query/HarbormasterBuildPlanSearchEngine.php
+++ b/src/applications/harbormaster/query/HarbormasterBuildPlanSearchEngine.php
@@ -17,6 +17,10 @@
protected function buildCustomSearchFields() {
return array(
+ id(new PhabricatorSearchTextField())
+ ->setLabel(pht('Name Contains'))
+ ->setKey('match')
+ ->setDescription(pht('Search for namespaces by name substring.')),
id(new PhabricatorSearchCheckboxesField())
->setLabel(pht('Status'))
->setKey('status')
@@ -32,6 +36,10 @@
protected function buildQueryFromParameters(array $map) {
$query = $this->newQuery();
+ if ($map['match'] !== null) {
+ $query->withNameNgrams($map['match']);
+ }
+
if ($map['status']) {
$query->withStatuses($map['status']);
}
diff --git a/src/applications/harbormaster/storage/configuration/HarbormasterBuildPlan.php b/src/applications/harbormaster/storage/configuration/HarbormasterBuildPlan.php
--- a/src/applications/harbormaster/storage/configuration/HarbormasterBuildPlan.php
+++ b/src/applications/harbormaster/storage/configuration/HarbormasterBuildPlan.php
@@ -7,7 +7,8 @@
implements
PhabricatorApplicationTransactionInterface,
PhabricatorPolicyInterface,
- PhabricatorSubscribableInterface {
+ PhabricatorSubscribableInterface,
+ PhabricatorNgramsInterface {
protected $name;
protected $planStatus;
@@ -198,4 +199,15 @@
return $messages;
}
+
+/* -( PhabricatorNgramInterface )------------------------------------------ */
+
+
+ public function newNgrams() {
+ return array(
+ id(new HarbormasterBuildPlanNameNgrams())
+ ->setValue($this->getName()),
+ );
+ }
+
}
diff --git a/src/applications/harbormaster/storage/configuration/HarbormasterBuildPlanNameNgrams.php b/src/applications/harbormaster/storage/configuration/HarbormasterBuildPlanNameNgrams.php
new file mode 100644
--- /dev/null
+++ b/src/applications/harbormaster/storage/configuration/HarbormasterBuildPlanNameNgrams.php
@@ -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';
+ }
+
+}

File Metadata

Mime Type
text/plain
Expires
Sun, Mar 9, 6:35 PM (4 d, 16 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7390591
Default Alt Text
D15359.id37036.diff (7 KB)

Event Timeline