1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-18 11:30:55 +01:00

Make project token sorting and normalization a little less hacky

Summary:
Ref T8510. Use "\n" as a delimiter between name sections. Specifically, project "AAA" with tag "zzz" should be a better match for query "AAA" than project "AAA BBB" is.

Make use of this delimiter slighlty more obvious in the UI.

Test Plan:
  - Created projects "Phacility" and "Phacility Core Access".
  - Typed "Phacility".
  - Before patch: first hit is "Phacility Core Access".
  - After patch: first hit is "Phacility".
  - Viewed debugging output table, saw visual explanation of behavior.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T8510

Differential Revision: https://secure.phabricator.com/D16886
This commit is contained in:
epriestley 2016-11-17 04:13:39 -08:00
parent da8c378331
commit b02f64f6ee
4 changed files with 16 additions and 12 deletions

View file

@ -10,7 +10,7 @@ return array(
'conpherence.pkg.css' => '0b64e988',
'conpherence.pkg.js' => '6249a1cf',
'core.pkg.css' => '2f1ecc57',
'core.pkg.js' => '56f967a5',
'core.pkg.js' => 'f0648ee7',
'darkconsole.pkg.js' => 'e7393ebb',
'differential.pkg.css' => 'a4ba74b5',
'differential.pkg.js' => '634399e9',
@ -261,7 +261,7 @@ return array(
'rsrc/externals/javelin/lib/behavior.js' => '61cbc29a',
'rsrc/externals/javelin/lib/control/tokenizer/Tokenizer.js' => '8d3bc1b2',
'rsrc/externals/javelin/lib/control/typeahead/Typeahead.js' => '70baed2f',
'rsrc/externals/javelin/lib/control/typeahead/normalizer/TypeaheadNormalizer.js' => 'e6e25838',
'rsrc/externals/javelin/lib/control/typeahead/normalizer/TypeaheadNormalizer.js' => '185bbd53',
'rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadCompositeSource.js' => '503e17fd',
'rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadOnDemandSource.js' => '013ffff9',
'rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadPreloadedSource.js' => '54f314a0',
@ -747,7 +747,7 @@ return array(
'javelin-tokenizer' => '8d3bc1b2',
'javelin-typeahead' => '70baed2f',
'javelin-typeahead-composite-source' => '503e17fd',
'javelin-typeahead-normalizer' => 'e6e25838',
'javelin-typeahead-normalizer' => '185bbd53',
'javelin-typeahead-ondemand-source' => '013ffff9',
'javelin-typeahead-preloaded-source' => '54f314a0',
'javelin-typeahead-source' => '0fcf201c',
@ -1037,6 +1037,9 @@ return array(
'javelin-workflow',
'javelin-workboard-controller',
),
'185bbd53' => array(
'javelin-install',
),
'1aa4c968' => array(
'javelin-behavior',
'javelin-stratcom',
@ -2121,9 +2124,6 @@ return array(
'javelin-workflow',
'javelin-magical-init',
),
'e6e25838' => array(
'javelin-install',
),
'e9581f08' => array(
'javelin-behavior',
'javelin-stratcom',

View file

@ -103,15 +103,10 @@ final class PhabricatorProjectDatasource
$all_strings = array();
$all_strings[] = $proj->getDisplayName();
// Add an extra space after the name so that the original project
// sorts ahead of milestones. This is kind of a hack but ehh?
$all_strings[] = null;
foreach ($proj->getSlugs() as $project_slug) {
$all_strings[] = $project_slug->getSlug();
}
$all_strings = implode(' ', $all_strings);
$all_strings = implode("\n", $all_strings);
$proj_result = id(new PhabricatorTypeaheadResult())
->setName($all_strings)

View file

@ -311,6 +311,11 @@ final class PhabricatorTypeaheadModularDatasourceController
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->setForm($form);
// Make "\n" delimiters more visible.
foreach ($content as $key => $row) {
$content[$key][0] = str_replace("\n", '<\n>', $row[0]);
}
$table = new AphrontTableView($content);
$table->setHeaders(
array(

View file

@ -18,6 +18,10 @@ JX.install('TypeaheadNormalizer', {
// NOTE: We specifically normalize "(" and ")" into spaces so that
// we can match tokenizer functions like "members(project)".
// NOTE: We specifically do NOT normalize "\n" because it is used as
// a delimiter between components of typeahead result names, like the
// name of a project and its tags.
return ('' + str)
.toLocaleLowerCase()
.replace(/[\.,\/#!$%\^&\*;:{}=_`~]/g, '')