Repository: dart-lang/pub-dev (dart)

Issue:
Change 'search relevance' to 'top results' in ranking dropdown.

Pull request:
Fixes #8955.

Patch:
diff --git a/app/lib/frontend/templates/_consts.dart b/app/lib/frontend/templates/_consts.dart
index 1f47b0b46b..70602b20e6 100644
--- a/app/lib/frontend/templates/_consts.dart
+++ b/app/lib/frontend/templates/_consts.dart
@@ -84,18 +84,11 @@ class SortDict {
 
 final _sortDicts = const <SortDict>[
   SortDict(
-    id: 'listing_relevance',
-    label: 'listing relevance',
+    id: 'default_ranking',
+    label: 'default ranking',
     tooltip:
         'Packages are sorted by the combination of their overall score and '
-        'their specificity to the selected platform.',
-  ),
-  SortDict(
-    id: 'search_relevance',
-    label: 'search relevance',
-    tooltip:
-        'Packages are sorted by the combination of the text match, '
-        'their overall score and their specificity to the selected platform.',
+        'their relevance to matching the search query text.',
   ),
   SortDict(
     id: 'top',
@@ -134,7 +127,4 @@ final _sortDicts = const <SortDict>[
   ),
 ];
 
-List<SortDict> getSortDicts(bool isSearch) {
-  final removeId = isSearch ? 'listing_relevance' : 'search_relevance';
-  return _sortDicts.where((d) => d.id != removeId).toList();
-}
+List<SortDict> getSortDicts() => _sortDicts;
diff --git a/app/lib/frontend/templates/listing.dart b/app/lib/frontend/templates/listing.dart
index e1ee330628..c5390c1839 100644
--- a/app/lib/frontend/templates/listing.dart
+++ b/app/lib/frontend/templates/listing.dart
@@ -90,10 +90,8 @@ d.Node listingInfo({
 }
 
 d.Node _renderSortControl(SearchForm form) {
-  final isSearch = form.hasQuery;
-  final options = getSortDicts(isSearch);
-  final sortValue =
-      form.order?.name ?? (isSearch ? 'search_relevance' : 'listing_relevance');
+  final options = getSortDicts();
+  final sortValue = form.order?.name ?? 'default_ranking';
   final selected = options.firstWhere(
     (o) => o.id == sortValue,
     orElse: () => options.first,


Test patch:
diff --git a/app/test/frontend/golden/pkg_index_page.html b/app/test/frontend/golden/pkg_index_page.html
index d07692a691..ef0621df28 100644
--- a/app/test/frontend/golden/pkg_index_page.html
+++ b/app/test/frontend/golden/pkg_index_page.html
@@ -415,12 +415,12 @@ <h3 class="search-form-section-header foldable-button">
               packages
             </div>
             <div class="sort-control hoverable">
-              <div class="info-identifier" title="Packages are sorted by the combination of the text match, their overall score and their specificity to the selected platform.">
+              <div class="info-identifier" title="Packages are sorted by the combination of their overall score and their relevance to matching the search query text.">
                 Sort by
-                <button class="sort-control-selected">search relevance</button>
+                <button class="sort-control-selected">default ranking</button>
               </div>
               <div class="sort-control-popup">
-                <button class="sort-control-option selected" data-value="search_relevance">search relevance</button>
+                <button class="sort-control-option selected" data-value="default_ranking">default ranking</button>
                 <button class="sort-control-option" data-value="top">overall score</button>
                 <button class="sort-control-option" data-value="updated">recently updated</button>
                 <button class="sort-control-option" data-value="created">newest package</button>
diff --git a/app/test/frontend/golden/publisher_packages_page.html b/app/test/frontend/golden/publisher_packages_page.html
index 685fd53605..cdfb8cd143 100644
--- a/app/test/frontend/golden/publisher_packages_page.html
+++ b/app/test/frontend/golden/publisher_packages_page.html
@@ -169,12 +169,12 @@ <h1 class="title pub-monochrome-icon-hoverable">example.com</h1>
                       <code>example.com</code>
                     </div>
                     <div class="sort-control hoverable">
-                      <div class="info-identifier" title="Packages are sorted by the combination of their overall score and their specificity to the selected platform.">
+                      <div class="info-identifier" title="Packages are sorted by the combination of their overall score and their relevance to matching the search query text.">
                         Sort by
-                        <button class="sort-control-selected">listing relevance</button>
+                        <button class="sort-control-selected">default ranking</button>
                       </div>
                       <div class="sort-control-popup">
-                        <button class="sort-control-option selected" data-value="listing_relevance">listing relevance</button>
+                        <button class="sort-control-option selected" data-value="default_ranking">default ranking</button>
                         <button class="sort-control-option" data-value="top">overall score</button>
                         <button class="sort-control-option" data-value="updated">recently updated</button>
                         <button class="sort-control-option" data-value="created">newest package</button>
diff --git a/app/test/frontend/golden/publisher_unlisted_packages_page.html b/app/test/frontend/golden/publisher_unlisted_packages_page.html
index a603f5e3fc..95750c340e 100644
--- a/app/test/frontend/golden/publisher_unlisted_packages_page.html
+++ b/app/test/frontend/golden/publisher_unlisted_packages_page.html
@@ -169,12 +169,12 @@ <h1 class="title pub-monochrome-icon-hoverable">example.com</h1>
                       <code>example.com</code>
                     </div>
                     <div class="sort-control hoverable">
-                      <div class="info-identifier" title="Packages are sorted by the combination of their overall score and their specificity to the selected platform.">
+                      <div class="info-identifier" title="Packages are sorted by the combination of their overall score and their relevance to matching the search query text.">
                         Sort by
-                        <button class="sort-control-selected">listing relevance</button>
+                        <button class="sort-control-selected">default ranking</button>
                       </div>
                       <div class="sort-control-popup">
-                        <button class="sort-control-option selected" data-value="listing_relevance">listing relevance</button>
+                        <button class="sort-control-option selected" data-value="default_ranking">default ranking</button>
                         <button class="sort-control-option" data-value="top">overall score</button>
                         <button class="sort-control-option" data-value="updated">recently updated</button>
                         <button class="sort-control-option" data-value="created">newest package</button>
diff --git a/app/test/frontend/golden/search_page.html b/app/test/frontend/golden/search_page.html
index 42dc584eec..609127d291 100644
--- a/app/test/frontend/golden/search_page.html
+++ b/app/test/frontend/golden/search_page.html
@@ -421,7 +421,7 @@ <h3 class="search-form-section-header foldable-button">
                 <button class="sort-control-selected">overall score</button>
               </div>
               <div class="sort-control-popup">
-                <button class="sort-control-option" data-value="search_relevance">search relevance</button>
+                <button class="sort-control-option" data-value="default_ranking">default ranking</button>
                 <button class="sort-control-option selected" data-value="top">overall score</button>
                 <button class="sort-control-option" data-value="updated">recently updated</button>
                 <button class="sort-control-option" data-value="created">newest package</button>