1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-29 16:08:22 +01:00

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
This commit is contained in:
Bob Trahan 2014-08-14 12:28:11 -07:00
parent cebbca9e08
commit 0b7bae29c8
5 changed files with 10 additions and 12 deletions

View file

@ -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',

View file

@ -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:

View file

@ -9,6 +9,7 @@ final class PhabricatorProjectSearchIndexer
protected function buildAbstractDocumentByPHID($phid) {
$project = $this->loadDocumentByPHID($phid);
$project->updateDatasourceTokens();
$doc = new PhabricatorSearchAbstractDocument();
$doc->setPHID($project->getPHID());

View file

@ -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);
}

View file

@ -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, '');
}