Skip to content

Remove topics match experiment. #8742

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions app/lib/frontend/handlers/experimental.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import '../../shared/cookie_utils.dart';
typedef PublicFlag = ({String name, String description});

const _publicFlags = <PublicFlag>{
(name: 'search-topics', description: 'Show matching topics when searching'),
(name: 'example', description: 'Short description'),
};

final _allFlags = <String>{
Expand Down Expand Up @@ -86,8 +86,6 @@ class ExperimentalFlags {
return params;
}

bool get isSearchTopicsEnabled => isEnabled('search-topics');

bool get isDarkModeDefault => isEnabled('dark-as-default');

String encodedAsCookie() => _enabled.join(':');
Expand Down
25 changes: 0 additions & 25 deletions app/lib/frontend/templates/listing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'dart:math';

import 'package:_pub_shared/search/search_form.dart';
import 'package:collection/collection.dart';
import 'package:pub_dev/frontend/request_context.dart';

import '../../package/search_adapter.dart';
import '../../search/search_service.dart';
Expand Down Expand Up @@ -52,9 +51,6 @@ String renderPkgIndexPage(
messageFromBackend: searchResultPage.errorMessage,
),
nameMatches: _nameMatches(searchForm, searchResultPage.nameMatches),
topicMatches: requestContext.experimentalFlags.isSearchTopicsEnabled
? _topicMatches(searchForm, searchResultPage.topicMatches)
: null,
packageList: packageList(searchResultPage),
pagination: searchResultPage.hasHit ? paginationNode(links) : null,
openSections: openSections,
Expand Down Expand Up @@ -151,24 +147,3 @@ d.Node? _nameMatches(SearchForm form, List<String>? matches) {
}),
]);
}

d.Node? _topicMatches(SearchForm form, List<String>? matches) {
if (matches == null || matches.isEmpty) {
return null;
}
final singular = matches.length == 1;
final isExactNameMatch = singular && form.parsedQuery.text == matches.single;
final nameMatchLabel = isExactNameMatch
? 'Exact topic match: '
: 'Matching ${singular ? 'topic' : 'topics'}: ';

return d.p(children: [
d.text(nameMatchLabel),
...matches.expandIndexed((i, name) {
return [
if (i > 0) d.text(', '),
d.a(href: urls.searchUrl(q: 'topic:$name'), text: '#$name'),
];
}),
]);
}
9 changes: 2 additions & 7 deletions app/lib/frontend/templates/views/pkg/index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,16 @@ d.Node packageListingNode({
required SearchForm searchForm,
required d.Node listingInfo,
required d.Node? nameMatches,
required d.Node? topicMatches,
required d.Node packageList,
required d.Node? pagination,
required Set<String>? openSections,
}) {
final matchHighlights = [
if (nameMatches != null) nameMatches,
if (topicMatches != null) topicMatches,
];
final innerContent = d.fragment([
listingInfo,
if (matchHighlights.isNotEmpty)
if (nameMatches != null)
d.div(
classes: ['listing-highlight-block'],
children: matchHighlights,
child: nameMatches,
),
packageList,
if (pagination != null) pagination,
Expand Down
5 changes: 0 additions & 5 deletions app/lib/package/search_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ class SearchAdapter {
form,
result.totalCount,
nameMatches: result.nameMatches,
topicMatches: result.topicMatches,
sdkLibraryHits: result.sdkLibraryHits,
packageHits:
result.packageHits.map((h) => views[h.package]).nonNulls.toList(),
Expand Down Expand Up @@ -149,9 +148,6 @@ class SearchResultPage {
/// would be considered as blocker for publishing).
final List<String>? nameMatches;

/// Topic names that are exact name matches or are close to a known topic.
final List<String>? topicMatches;

/// The hits from the SDK libraries.
final List<SdkLibraryHit> sdkLibraryHits;

Expand All @@ -169,7 +165,6 @@ class SearchResultPage {
this.form,
this.totalCount, {
this.nameMatches,
this.topicMatches,
List<SdkLibraryHit>? sdkLibraryHits,
List<PackageView>? packageHits,
this.errorMessage,
Expand Down
14 changes: 0 additions & 14 deletions app/lib/search/mem_index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -230,19 +230,6 @@ class InMemoryPackageIndex {
);

final nameMatches = textResults?.nameMatches;
List<String>? topicMatches;

if (parsedQueryText != null) {
final parts = parsedQueryText
.split(' ')
.map((t) => canonicalTopics.aliasToCanonicalMap[t] ?? t)
.toSet()
.where(_topics.contains)
.toList();
if (parts.isNotEmpty) {
topicMatches = parts;
}
}

List<IndexedPackageHit> indexedHits;
switch (query.effectiveOrder ?? SearchOrder.top) {
Expand Down Expand Up @@ -306,7 +293,6 @@ class InMemoryPackageIndex {
timestamp: clock.now().toUtc(),
totalCount: totalCount,
nameMatches: nameMatches,
topicMatches: topicMatches,
packageHits: packageHits,
errorMessage: textResults?.errorMessage,
);
Expand Down
5 changes: 0 additions & 5 deletions app/lib/search/search_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,6 @@ class PackageSearchResult {
/// would be considered as blocker for publishing).
final List<String>? nameMatches;

/// Topic names that are exact name matches or close to the queried text.
final List<String>? topicMatches;
final List<SdkLibraryHit> sdkLibraryHits;
final List<PackageHit> packageHits;

Expand All @@ -376,7 +374,6 @@ class PackageSearchResult {
required this.timestamp,
required this.totalCount,
this.nameMatches,
this.topicMatches,
List<SdkLibraryHit>? sdkLibraryHits,
List<PackageHit>? packageHits,
this.errorMessage,
Expand All @@ -396,7 +393,6 @@ class PackageSearchResult {
}) : timestamp = clock.now().toUtc(),
totalCount = 0,
nameMatches = null,
topicMatches = null,
sdkLibraryHits = <SdkLibraryHit>[],
packageHits = <PackageHit>[];

Expand All @@ -416,7 +412,6 @@ class PackageSearchResult {
timestamp: timestamp,
totalCount: totalCount,
nameMatches: nameMatches,
topicMatches: topicMatches,
sdkLibraryHits: sdkLibraryHits ?? this.sdkLibraryHits,
packageHits: packageHits,
errorMessage: errorMessage,
Expand Down
4 changes: 0 additions & 4 deletions app/lib/search/search_service.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.