From 0b7bae29c8bbbf5f6903c3e2c1c7d6a6f8183050 Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Thu, 14 Aug 2014 12:28:11 -0700 Subject: [PATCH] Projects - tokenize projects more aggressively with respect to '-' Summary: Fixes T5727. Updates the regexes to split on '-'. Also changes the editor such that tokens are updated by the larger search process. (Note this means we update this data more often then we need to - for every project transaction.) Users will need to make an edit to a project -or- run `bin/search index "#project-tag"` to make this actually work. Test Plan: Made "Frontend-Engineering", "Engineering", and "Backend-Enginering". They all showed up in the typeahead! Reviewers: epriestley Reviewed By: epriestley Subscribers: epriestley, Korvin Maniphest Tasks: T5727 Differential Revision: https://secure.phabricator.com/D10247 --- resources/celerity/map.php | 12 ++++++------ .../editor/PhabricatorProjectTransactionEditor.php | 4 ---- .../search/PhabricatorProjectSearchIndexer.php | 1 + .../datasource/PhabricatorTypeaheadDatasource.php | 2 +- .../typeahead/normalizer/TypeaheadNormalizer.js | 3 ++- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/resources/celerity/map.php b/resources/celerity/map.php index 95267795fe..e5938a988a 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -8,7 +8,7 @@ return array( 'names' => array( 'core.pkg.css' => 'f8054294', - 'core.pkg.js' => '14887b3d', + 'core.pkg.js' => '7c8455ef', 'darkconsole.pkg.js' => 'df001cab', 'differential.pkg.css' => '4a93db37', 'differential.pkg.js' => 'eb182ccd', @@ -212,7 +212,7 @@ return array( 'rsrc/externals/javelin/lib/behavior.js' => '61cbc29a', 'rsrc/externals/javelin/lib/control/tokenizer/Tokenizer.js' => 'a5b67173', 'rsrc/externals/javelin/lib/control/typeahead/Typeahead.js' => 'e614d22b', - 'rsrc/externals/javelin/lib/control/typeahead/normalizer/TypeaheadNormalizer.js' => 'aa93c7b0', + 'rsrc/externals/javelin/lib/control/typeahead/normalizer/TypeaheadNormalizer.js' => '1c22377d', 'rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadCompositeSource.js' => '503e17fd', 'rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadOnDemandSource.js' => '8b3fd187', 'rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadPreloadedSource.js' => '54f314a0', @@ -681,7 +681,7 @@ return array( 'javelin-tokenizer' => 'a5b67173', 'javelin-typeahead' => 'e614d22b', 'javelin-typeahead-composite-source' => '503e17fd', - 'javelin-typeahead-normalizer' => 'aa93c7b0', + 'javelin-typeahead-normalizer' => '1c22377d', 'javelin-typeahead-ondemand-source' => '8b3fd187', 'javelin-typeahead-preloaded-source' => '54f314a0', 'javelin-typeahead-source' => 'fcba4ecc', @@ -967,6 +967,9 @@ return array( 'javelin-util', 'phabricator-keyboard-shortcut-manager', ), + '1c22377d' => array( + 'javelin-install', + ), '1def2711' => array( 'javelin-install', 'javelin-dom', @@ -1515,9 +1518,6 @@ return array( 'javelin-util', 'phabricator-prefab', ), - 'aa93c7b0' => array( - 'javelin-install', - ), 'ab836011' => array( 'javelin-behavior', 'javelin-dom', diff --git a/src/applications/project/editor/PhabricatorProjectTransactionEditor.php b/src/applications/project/editor/PhabricatorProjectTransactionEditor.php index 202d36ad59..6d86a774cb 100644 --- a/src/applications/project/editor/PhabricatorProjectTransactionEditor.php +++ b/src/applications/project/editor/PhabricatorProjectTransactionEditor.php @@ -133,8 +133,6 @@ final class PhabricatorProjectTransactionEditor ->setProjectPHID($object->getPHID()) ->save(); - $object->updateDatasourceTokens(); - // TODO -- delete all of the below once we sever automagical project // to phriction stuff if ($xaction->getOldValue() === null) { @@ -193,8 +191,6 @@ final class PhabricatorProjectTransactionEditor } } - $object->updateDatasourceTokens(); - return; case PhabricatorTransactions::TYPE_VIEW_POLICY: case PhabricatorTransactions::TYPE_EDIT_POLICY: diff --git a/src/applications/project/search/PhabricatorProjectSearchIndexer.php b/src/applications/project/search/PhabricatorProjectSearchIndexer.php index 2b046297a7..a4fb7eaf87 100644 --- a/src/applications/project/search/PhabricatorProjectSearchIndexer.php +++ b/src/applications/project/search/PhabricatorProjectSearchIndexer.php @@ -9,6 +9,7 @@ final class PhabricatorProjectSearchIndexer protected function buildAbstractDocumentByPHID($phid) { $project = $this->loadDocumentByPHID($phid); + $project->updateDatasourceTokens(); $doc = new PhabricatorSearchAbstractDocument(); $doc->setPHID($project->getPHID()); diff --git a/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php b/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php index e88a66ae8a..faf01795da 100644 --- a/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php +++ b/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php @@ -74,7 +74,7 @@ abstract class PhabricatorTypeaheadDatasource extends Phobject { return array(); } - $tokens = preg_split('/\s+/', $string); + $tokens = preg_split('/\s+|-/', $string); return array_unique($tokens); } diff --git a/webroot/rsrc/externals/javelin/lib/control/typeahead/normalizer/TypeaheadNormalizer.js b/webroot/rsrc/externals/javelin/lib/control/typeahead/normalizer/TypeaheadNormalizer.js index 5611ea6252..d048b67e47 100644 --- a/webroot/rsrc/externals/javelin/lib/control/typeahead/normalizer/TypeaheadNormalizer.js +++ b/webroot/rsrc/externals/javelin/lib/control/typeahead/normalizer/TypeaheadNormalizer.js @@ -16,7 +16,8 @@ JX.install('TypeaheadNormalizer', { normalize : function(str) { return ('' + str) .toLocaleLowerCase() - .replace(/[\.,-\/#!$%\^&\*;:{}=\-_`~()]/g, '') + .replace(/[\.,\/#!$%\^&\*;:{}=_`~()]/g, '') + .replace(/-/g, ' ') .replace(/ +/g, ' ') .replace(/^\s*|\s*$/g, ''); }