Page MenuHomePhabricator

D17090.id41105.diff
No OneTemporary

D17090.id41105.diff

diff --git a/resources/sql/autopatches/20161216.dashboard.ngram.01.sql b/resources/sql/autopatches/20161216.dashboard.ngram.01.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20161216.dashboard.ngram.01.sql
@@ -0,0 +1,15 @@
+CREATE TABLE {$NAMESPACE}_dashboard.dashboard_dashboard_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};
+
+CREATE TABLE {$NAMESPACE}_dashboard.dashboard_dashboardpanel_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/20161216.dashboard.ngram.02.php b/resources/sql/autopatches/20161216.dashboard.ngram.02.php
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20161216.dashboard.ngram.02.php
@@ -0,0 +1,21 @@
+<?php
+
+$table_db = new PhabricatorDashboard();
+
+foreach (new LiskMigrationIterator($table_db) as $dashboard) {
+ PhabricatorSearchWorker::queueDocumentForIndexing(
+ $dashboard->getPHID(),
+ array(
+ 'force' => true,
+ ));
+}
+
+$table_dbp = new PhabricatorDashboardPanel();
+
+foreach (new LiskMigrationIterator($table_dbp) as $panel) {
+ PhabricatorSearchWorker::queueDocumentForIndexing(
+ $panel->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
@@ -2457,6 +2457,7 @@
'PhabricatorDashboardListController' => 'applications/dashboard/controller/PhabricatorDashboardListController.php',
'PhabricatorDashboardManageController' => 'applications/dashboard/controller/PhabricatorDashboardManageController.php',
'PhabricatorDashboardMovePanelController' => 'applications/dashboard/controller/PhabricatorDashboardMovePanelController.php',
+ 'PhabricatorDashboardNgrams' => 'applications/dashboard/storage/PhabricatorDashboardNgrams.php',
'PhabricatorDashboardPanel' => 'applications/dashboard/storage/PhabricatorDashboardPanel.php',
'PhabricatorDashboardPanelArchiveController' => 'applications/dashboard/controller/PhabricatorDashboardPanelArchiveController.php',
'PhabricatorDashboardPanelCoreCustomField' => 'applications/dashboard/customfield/PhabricatorDashboardPanelCoreCustomField.php',
@@ -2468,6 +2469,7 @@
'PhabricatorDashboardPanelEditproController' => 'applications/dashboard/controller/PhabricatorDashboardPanelEditproController.php',
'PhabricatorDashboardPanelHasDashboardEdgeType' => 'applications/dashboard/edge/PhabricatorDashboardPanelHasDashboardEdgeType.php',
'PhabricatorDashboardPanelListController' => 'applications/dashboard/controller/PhabricatorDashboardPanelListController.php',
+ 'PhabricatorDashboardPanelNgrams' => 'applications/dashboard/storage/PhabricatorDashboardPanelNgrams.php',
'PhabricatorDashboardPanelPHIDType' => 'applications/dashboard/phid/PhabricatorDashboardPanelPHIDType.php',
'PhabricatorDashboardPanelQuery' => 'applications/dashboard/query/PhabricatorDashboardPanelQuery.php',
'PhabricatorDashboardPanelRenderController' => 'applications/dashboard/controller/PhabricatorDashboardPanelRenderController.php',
@@ -7405,6 +7407,7 @@
'PhabricatorFlaggableInterface',
'PhabricatorDestructibleInterface',
'PhabricatorProjectInterface',
+ 'PhabricatorNgramsInterface',
),
'PhabricatorDashboardAddPanelController' => 'PhabricatorDashboardController',
'PhabricatorDashboardApplication' => 'PhabricatorApplication',
@@ -7423,6 +7426,7 @@
'PhabricatorDashboardListController' => 'PhabricatorDashboardController',
'PhabricatorDashboardManageController' => 'PhabricatorDashboardController',
'PhabricatorDashboardMovePanelController' => 'PhabricatorDashboardController',
+ 'PhabricatorDashboardNgrams' => 'PhabricatorSearchNgrams',
'PhabricatorDashboardPanel' => array(
'PhabricatorDashboardDAO',
'PhabricatorApplicationTransactionInterface',
@@ -7430,6 +7434,7 @@
'PhabricatorCustomFieldInterface',
'PhabricatorFlaggableInterface',
'PhabricatorDestructibleInterface',
+ 'PhabricatorNgramsInterface',
),
'PhabricatorDashboardPanelArchiveController' => 'PhabricatorDashboardController',
'PhabricatorDashboardPanelCoreCustomField' => array(
@@ -7444,6 +7449,7 @@
'PhabricatorDashboardPanelEditproController' => 'PhabricatorDashboardController',
'PhabricatorDashboardPanelHasDashboardEdgeType' => 'PhabricatorEdgeType',
'PhabricatorDashboardPanelListController' => 'PhabricatorDashboardController',
+ 'PhabricatorDashboardPanelNgrams' => 'PhabricatorSearchNgrams',
'PhabricatorDashboardPanelPHIDType' => 'PhabricatorPHIDType',
'PhabricatorDashboardPanelQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorDashboardPanelRenderController' => 'PhabricatorDashboardController',
diff --git a/src/applications/dashboard/editor/PhabricatorDashboardPanelEditEngine.php b/src/applications/dashboard/editor/PhabricatorDashboardPanelEditEngine.php
--- a/src/applications/dashboard/editor/PhabricatorDashboardPanelEditEngine.php
+++ b/src/applications/dashboard/editor/PhabricatorDashboardPanelEditEngine.php
@@ -28,12 +28,16 @@
return pht('Edit Dashboard Panels');
}
+ protected function supportsSearch() {
+ return true;
+ }
+
public function getSummaryText() {
return pht('This engine is used to modify dashboard panels.');
}
public function getEngineApplicationClass() {
- return 'PhabricatorSearchApplication';
+ return 'PhabricatorDashboardApplication';
}
protected function newEditableObject() {
diff --git a/src/applications/dashboard/query/PhabricatorDashboardPanelQuery.php b/src/applications/dashboard/query/PhabricatorDashboardPanelQuery.php
--- a/src/applications/dashboard/query/PhabricatorDashboardPanelQuery.php
+++ b/src/applications/dashboard/query/PhabricatorDashboardPanelQuery.php
@@ -34,6 +34,12 @@
return $this;
}
+ public function withNameNgrams($ngrams) {
+ return $this->withNgramsConstraint(
+ id(new PhabricatorDashboardPanelNgrams()),
+ $ngrams);
+ }
+
protected function loadPage() {
return $this->loadStandardPage($this->newResultObject());
}
@@ -95,4 +101,8 @@
return 'PhabricatorDashboardApplication';
}
+ protected function getPrimaryTableAlias() {
+ return 'dashboard_panel';
+ }
+
}
diff --git a/src/applications/dashboard/query/PhabricatorDashboardPanelSearchEngine.php b/src/applications/dashboard/query/PhabricatorDashboardPanelSearchEngine.php
--- a/src/applications/dashboard/query/PhabricatorDashboardPanelSearchEngine.php
+++ b/src/applications/dashboard/query/PhabricatorDashboardPanelSearchEngine.php
@@ -38,12 +38,20 @@
$query->withAuthorPHIDs($map['authorPHIDs']);
}
+ if ($map['name'] !== null) {
+ $query->withNameNgrams($map['name']);
+ }
+
return $query;
}
protected function buildCustomSearchFields() {
return array(
+ id(new PhabricatorSearchTextField())
+ ->setLabel(pht('Name Contains'))
+ ->setKey('name')
+ ->setDescription(pht('Search for badges by name substring.')),
id(new PhabricatorSearchDatasourceField())
->setLabel(pht('Authored By'))
->setKey('authorPHIDs')
diff --git a/src/applications/dashboard/query/PhabricatorDashboardQuery.php b/src/applications/dashboard/query/PhabricatorDashboardQuery.php
--- a/src/applications/dashboard/query/PhabricatorDashboardQuery.php
+++ b/src/applications/dashboard/query/PhabricatorDashboardQuery.php
@@ -41,6 +41,12 @@
return $this;
}
+ public function withNameNgrams($ngrams) {
+ return $this->withNgramsConstraint(
+ id(new PhabricatorDashboardNgrams()),
+ $ngrams);
+ }
+
protected function loadPage() {
return $this->loadStandardPage($this->newResultObject());
}
@@ -141,4 +147,8 @@
return 'PhabricatorDashboardApplication';
}
+ protected function getPrimaryTableAlias() {
+ return 'dashboard';
+ }
+
}
diff --git a/src/applications/dashboard/query/PhabricatorDashboardSearchEngine.php b/src/applications/dashboard/query/PhabricatorDashboardSearchEngine.php
--- a/src/applications/dashboard/query/PhabricatorDashboardSearchEngine.php
+++ b/src/applications/dashboard/query/PhabricatorDashboardSearchEngine.php
@@ -18,6 +18,10 @@
protected function buildCustomSearchFields() {
return array(
+ id(new PhabricatorSearchTextField())
+ ->setLabel(pht('Name Contains'))
+ ->setKey('name')
+ ->setDescription(pht('Search for badges by name substring.')),
id(new PhabricatorSearchDatasourceField())
->setLabel(pht('Authored By'))
->setKey('authorPHIDs')
@@ -82,6 +86,10 @@
$query->withAuthorPHIDs($map['authorPHIDs']);
}
+ if ($map['name'] !== null) {
+ $query->withNameNgrams($map['name']);
+ }
+
return $query;
}
diff --git a/src/applications/dashboard/storage/PhabricatorDashboard.php b/src/applications/dashboard/storage/PhabricatorDashboard.php
--- a/src/applications/dashboard/storage/PhabricatorDashboard.php
+++ b/src/applications/dashboard/storage/PhabricatorDashboard.php
@@ -9,7 +9,8 @@
PhabricatorPolicyInterface,
PhabricatorFlaggableInterface,
PhabricatorDestructibleInterface,
- PhabricatorProjectInterface {
+ PhabricatorProjectInterface,
+ PhabricatorNgramsInterface {
protected $name;
protected $authorPHID;
@@ -63,7 +64,7 @@
'layoutConfig' => self::SERIALIZATION_JSON,
),
self::CONFIG_COLUMN_SCHEMA => array(
- 'name' => 'text255',
+ 'name' => 'sort255',
'status' => 'text32',
'icon' => 'text32',
'authorPHID' => 'phid',
@@ -186,4 +187,14 @@
}
+/* -( PhabricatorNgramInterface )------------------------------------------ */
+
+
+ public function newNgrams() {
+ return array(
+ id(new PhabricatorDashboardNgrams())
+ ->setValue($this->getName()),
+ );
+ }
+
}
diff --git a/src/applications/dashboard/storage/PhabricatorDashboardNgrams.php b/src/applications/dashboard/storage/PhabricatorDashboardNgrams.php
new file mode 100644
--- /dev/null
+++ b/src/applications/dashboard/storage/PhabricatorDashboardNgrams.php
@@ -0,0 +1,18 @@
+<?php
+
+final class PhabricatorDashboardNgrams
+ extends PhabricatorSearchNgrams {
+
+ public function getNgramKey() {
+ return 'dashboard';
+ }
+
+ public function getColumnName() {
+ return 'name';
+ }
+
+ public function getApplicationName() {
+ return 'dashboard';
+ }
+
+}
diff --git a/src/applications/dashboard/storage/PhabricatorDashboardPanel.php b/src/applications/dashboard/storage/PhabricatorDashboardPanel.php
--- a/src/applications/dashboard/storage/PhabricatorDashboardPanel.php
+++ b/src/applications/dashboard/storage/PhabricatorDashboardPanel.php
@@ -10,7 +10,8 @@
PhabricatorPolicyInterface,
PhabricatorCustomFieldInterface,
PhabricatorFlaggableInterface,
- PhabricatorDestructibleInterface {
+ PhabricatorDestructibleInterface,
+ PhabricatorNgramsInterface {
protected $name;
protected $panelType;
@@ -50,7 +51,7 @@
'properties' => self::SERIALIZATION_JSON,
),
self::CONFIG_COLUMN_SCHEMA => array(
- 'name' => 'text255',
+ 'name' => 'sort255',
'panelType' => 'text64',
'authorPHID' => 'phid',
'isArchived' => 'bool',
@@ -197,4 +198,15 @@
$this->saveTransaction();
}
+
+/* -( PhabricatorNgramInterface )------------------------------------------ */
+
+
+ public function newNgrams() {
+ return array(
+ id(new PhabricatorDashboardPanelNgrams())
+ ->setValue($this->getName()),
+ );
+ }
+
}
diff --git a/src/applications/dashboard/storage/PhabricatorDashboardPanelNgrams.php b/src/applications/dashboard/storage/PhabricatorDashboardPanelNgrams.php
new file mode 100644
--- /dev/null
+++ b/src/applications/dashboard/storage/PhabricatorDashboardPanelNgrams.php
@@ -0,0 +1,18 @@
+<?php
+
+final class PhabricatorDashboardPanelNgrams
+ extends PhabricatorSearchNgrams {
+
+ public function getNgramKey() {
+ return 'dashboardpanel';
+ }
+
+ public function getColumnName() {
+ return 'name';
+ }
+
+ public function getApplicationName() {
+ return 'dashboard';
+ }
+
+}

File Metadata

Mime Type
text/plain
Expires
Wed, Dec 18, 4:30 PM (3 h, 8 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6903549
Default Alt Text
D17090.id41105.diff (12 KB)

Event Timeline