Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15278813
D15389.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D15389.diff
View Options
diff --git a/resources/sql/autopatches/20160303.drydock.1.bluen.sql b/resources/sql/autopatches/20160303.drydock.1.bluen.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20160303.drydock.1.bluen.sql
@@ -0,0 +1,7 @@
+CREATE TABLE {$NAMESPACE}_drydock.drydock_blueprintname_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/20160303.drydock.2.bluei.php b/resources/sql/autopatches/20160303.drydock.2.bluei.php
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20160303.drydock.2.bluei.php
@@ -0,0 +1,11 @@
+<?php
+
+$table = new DrydockBlueprint();
+
+foreach (new LiskMigrationIterator($table) as $blueprint) {
+ PhabricatorSearchWorker::queueDocumentForIndexing(
+ $blueprint->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
@@ -876,6 +876,7 @@
'DrydockBlueprintImplementation' => 'applications/drydock/blueprint/DrydockBlueprintImplementation.php',
'DrydockBlueprintImplementationTestCase' => 'applications/drydock/blueprint/__tests__/DrydockBlueprintImplementationTestCase.php',
'DrydockBlueprintListController' => 'applications/drydock/controller/DrydockBlueprintListController.php',
+ 'DrydockBlueprintNameNgrams' => 'applications/drydock/storage/DrydockBlueprintNameNgrams.php',
'DrydockBlueprintPHIDType' => 'applications/drydock/phid/DrydockBlueprintPHIDType.php',
'DrydockBlueprintQuery' => 'applications/drydock/query/DrydockBlueprintQuery.php',
'DrydockBlueprintSearchEngine' => 'applications/drydock/query/DrydockBlueprintSearchEngine.php',
@@ -4972,6 +4973,7 @@
'PhabricatorApplicationTransactionInterface',
'PhabricatorPolicyInterface',
'PhabricatorCustomFieldInterface',
+ 'PhabricatorNgramsInterface',
),
'DrydockBlueprintController' => 'DrydockController',
'DrydockBlueprintCoreCustomField' => array(
@@ -4987,6 +4989,7 @@
'DrydockBlueprintImplementation' => 'Phobject',
'DrydockBlueprintImplementationTestCase' => 'PhabricatorTestCase',
'DrydockBlueprintListController' => 'DrydockBlueprintController',
+ 'DrydockBlueprintNameNgrams' => 'PhabricatorSearchNgrams',
'DrydockBlueprintPHIDType' => 'PhabricatorPHIDType',
'DrydockBlueprintQuery' => 'DrydockQuery',
'DrydockBlueprintSearchEngine' => 'PhabricatorApplicationSearchEngine',
diff --git a/src/applications/drydock/controller/DrydockBlueprintListController.php b/src/applications/drydock/controller/DrydockBlueprintListController.php
--- a/src/applications/drydock/controller/DrydockBlueprintListController.php
+++ b/src/applications/drydock/controller/DrydockBlueprintListController.php
@@ -7,15 +7,9 @@
}
public function handleRequest(AphrontRequest $request) {
- $querykey = $request->getURIData('queryKey');
-
- $request = $this->getRequest();
- $controller = id(new PhabricatorApplicationSearchController())
- ->setQueryKey($querykey)
- ->setSearchEngine(new DrydockBlueprintSearchEngine())
- ->setNavigation($this->buildSideNavView());
-
- return $this->delegateToController($controller);
+ return id(new DrydockBlueprintSearchEngine())
+ ->setController($this)
+ ->buildResponse();
}
protected function buildApplicationCrumbs() {
diff --git a/src/applications/drydock/editor/DrydockBlueprintEditor.php b/src/applications/drydock/editor/DrydockBlueprintEditor.php
--- a/src/applications/drydock/editor/DrydockBlueprintEditor.php
+++ b/src/applications/drydock/editor/DrydockBlueprintEditor.php
@@ -11,6 +11,10 @@
return pht('Drydock Blueprints');
}
+ protected function supportsSearch() {
+ return true;
+ }
+
public function getTransactionTypes() {
$types = parent::getTransactionTypes();
diff --git a/src/applications/drydock/query/DrydockBlueprintQuery.php b/src/applications/drydock/query/DrydockBlueprintQuery.php
--- a/src/applications/drydock/query/DrydockBlueprintQuery.php
+++ b/src/applications/drydock/query/DrydockBlueprintQuery.php
@@ -39,6 +39,12 @@
return $this;
}
+ public function withNameNgrams($ngrams) {
+ return $this->withNgramsConstraint(
+ new DrydockBlueprintNameNgrams(),
+ $ngrams);
+ }
+
public function newResultObject() {
return new DrydockBlueprint();
}
diff --git a/src/applications/drydock/query/DrydockBlueprintSearchEngine.php b/src/applications/drydock/query/DrydockBlueprintSearchEngine.php
--- a/src/applications/drydock/query/DrydockBlueprintSearchEngine.php
+++ b/src/applications/drydock/query/DrydockBlueprintSearchEngine.php
@@ -18,6 +18,10 @@
protected function buildQueryFromParameters(array $map) {
$query = $this->newQuery();
+ if ($map['match'] !== null) {
+ $query->withNameNgrams($map['match']);
+ }
+
if ($map['isDisabled'] !== null) {
$query->withDisabled($map['isDisabled']);
}
@@ -27,6 +31,10 @@
protected function buildCustomSearchFields() {
return array(
+ id(new PhabricatorSearchTextField())
+ ->setLabel(pht('Name Contains'))
+ ->setKey('match')
+ ->setDescription(pht('Search for blueprints by name substring.')),
id(new PhabricatorSearchThreeStateField())
->setLabel(pht('Disabled'))
->setKey('isDisabled')
diff --git a/src/applications/drydock/storage/DrydockBlueprint.php b/src/applications/drydock/storage/DrydockBlueprint.php
--- a/src/applications/drydock/storage/DrydockBlueprint.php
+++ b/src/applications/drydock/storage/DrydockBlueprint.php
@@ -8,7 +8,8 @@
implements
PhabricatorApplicationTransactionInterface,
PhabricatorPolicyInterface,
- PhabricatorCustomFieldInterface {
+ PhabricatorCustomFieldInterface,
+ PhabricatorNgramsInterface {
protected $className;
protected $blueprintName;
@@ -343,4 +344,14 @@
}
+/* -( PhabricatorNgramInterface )------------------------------------------ */
+
+
+ public function newNgrams() {
+ return array(
+ id(new DrydockBlueprintNameNgrams())
+ ->setValue($this->getBlueprintName()),
+ );
+ }
+
}
diff --git a/src/applications/drydock/storage/DrydockBlueprintNameNgrams.php b/src/applications/drydock/storage/DrydockBlueprintNameNgrams.php
new file mode 100644
--- /dev/null
+++ b/src/applications/drydock/storage/DrydockBlueprintNameNgrams.php
@@ -0,0 +1,18 @@
+<?php
+
+final class DrydockBlueprintNameNgrams
+ extends PhabricatorSearchNgrams {
+
+ public function getNgramKey() {
+ return 'blueprintname';
+ }
+
+ public function getColumnName() {
+ return 'blueprintName';
+ }
+
+ public function getApplicationName() {
+ return 'drydock';
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Mar 3, 11:45 PM (6 h, 12 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7220075
Default Alt Text
D15389.diff (6 KB)
Attached To
Mode
D15389: Allow Drydock blueprints to be searched by name
Attached
Detach File
Event Timeline
Log In to Comment