1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 03:50:54 +01:00

Sort project typeahead tokens by display name, not hashtag

Summary:
Fixes T8510. Results are internally ordered by "name", which is the full list of strings a user can type to match a result. On the balance, it is probably good/correct to order by this (particularly, it allows `function(x)` to sort near `x`).

However, the way projects were built put the tags first, so a project like "Discovery" could end up last if it had originally been created with a different name like "Search Team", so that its first slug is "search-team".

Instead, put the display name first in the ordering.

Test Plan:
{F1661775}

To reproduce in particular:

  - Create a project named "Zebra".
  - Create a lot of projects named "Armadillo-blahblahblah".
  - Rename "Zebra" to "Armadillo".

Before the patch, the new "Armadillo" project would still sort as though it were named "Zebra". After the patch, it sorts as expected normally.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T8510

Differential Revision: https://secure.phabricator.com/D15981
This commit is contained in:
epriestley 2016-05-26 10:01:44 -07:00
parent 5b77b86ffb
commit 727a7de759

View file

@ -82,8 +82,11 @@ final class PhabricatorProjectDatasource
$closed = pht('Archived');
}
$all_strings = mpull($proj->getSlugs(), 'getSlug');
$all_strings = array();
$all_strings[] = $proj->getDisplayName();
foreach ($proj->getSlugs() as $project_slug) {
$all_strings[] = $project_slug->getSlug();
}
$all_strings = implode(' ', $all_strings);
$proj_result = id(new PhabricatorTypeaheadResult())