Skip to content
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
14 changes: 2 additions & 12 deletions app/lib/search/mem_index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class InMemoryPackageIndex {
late final List<IndexedPackageHit> _overallOrderedHits;
late final List<IndexedPackageHit> _createdOrderedHits;
late final List<IndexedPackageHit> _updatedOrderedHits;
late final List<IndexedPackageHit> _popularityOrderedHits;
late final List<IndexedPackageHit> _downloadsOrderedHits;
late final List<IndexedPackageHit> _likesOrderedHits;
late final List<IndexedPackageHit> _pointsOrderedHits;
Expand Down Expand Up @@ -116,8 +115,6 @@ class InMemoryPackageIndex {
score: (doc) => doc.overallScore ?? 0.0);
_createdOrderedHits = _rankWithComparator(_compareCreated);
_updatedOrderedHits = _rankWithComparator(_compareUpdated);
_popularityOrderedHits = _rankWithComparator(_comparePopularity,
score: (doc) => doc.popularityScore ?? 0);
_downloadsOrderedHits = _rankWithComparator(_compareDownloads,
score: (doc) => doc.downloadCount.toDouble());
_likesOrderedHits = _rankWithComparator(_compareLikes,
Expand Down Expand Up @@ -271,9 +268,8 @@ class InMemoryPackageIndex {
case SearchOrder.updated:
indexedHits = _updatedOrderedHits.whereInScores(packageScores);
break;
// ignore: deprecated_member_use
case SearchOrder.popularity:
indexedHits = _popularityOrderedHits.whereInScores(packageScores);
break;
case SearchOrder.downloads:
indexedHits = _downloadsOrderedHits.whereInScores(packageScores);
break;
Expand Down Expand Up @@ -315,7 +311,7 @@ class InMemoryPackageIndex {
/// Update the overall score both on [PackageDocument] and in the [_adjustedOverallScores] map.
void _updateOverallScores() {
_adjustedOverallScores = _documents.map((doc) {
final downloadScore = doc.downloadScore ?? doc.popularityScore ?? 0.0;
final downloadScore = doc.downloadScore ?? 0.0;
final likeScore = doc.likeScore ?? 0.0;
final popularity = (downloadScore + likeScore) / 2;
final points = doc.grantedPoints / math.max(1, doc.maxPoints);
Expand Down Expand Up @@ -497,12 +493,6 @@ class InMemoryPackageIndex {
return _compareUpdated(a, b);
}

int _comparePopularity(PackageDocument a, PackageDocument b) {
final x = -(a.popularityScore ?? 0.0).compareTo(b.popularityScore ?? 0.0);
if (x != 0) return x;
return _compareUpdated(a, b);
}

int _compareDownloads(PackageDocument a, PackageDocument b) {
final x = -a.downloadCount.compareTo(b.downloadCount);
if (x != 0) return x;
Expand Down
4 changes: 0 additions & 4 deletions app/lib/search/search_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,6 @@ class PackageDocument {
/// The normalized score between [0.0-1.0] (1.0 being the most liked package).
double? likeScore;

/// The normalized score between [0.0-1.0] (1.0 being the most popular package).
double? popularityScore;

final int grantedPoints;
final int maxPoints;

Expand Down Expand Up @@ -114,7 +111,6 @@ class PackageDocument {
this.downloadScore,
int? likeCount,
this.likeScore,
this.popularityScore,
int? grantedPoints,
int? maxPoints,
this.dependencies = const {},
Expand Down
2 changes: 0 additions & 2 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.

2 changes: 1 addition & 1 deletion app/lib/search/top_packages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class TopPackages {
query: PackageTags.isFlutterFavorite,
);
final _mostPopular =
_cachedValue('top-packages-most-popular', order: SearchOrder.popularity);
_cachedValue('top-packages-most-popular', order: SearchOrder.downloads);
final _topDart = _cachedValue('top-packages-top-dart', query: SdkTag.sdkDart);
final _topFlutter =
_cachedValue('top-packages-top-flutter', query: SdkTag.sdkFlutter);
Expand Down
2 changes: 1 addition & 1 deletion app/lib/shared/urls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ String searchUrl({
}

String listingByPopularity() =>
SearchForm(order: SearchOrder.popularity).toSearchLink();
SearchForm(order: SearchOrder.downloads).toSearchLink();

String dartSdkMainUrl(String version) {
final isDev = version.contains('dev');
Expand Down
2 changes: 1 addition & 1 deletion app/test/frontend/golden/landing_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ <h3>oxygen</h3>
</div>
</div>
<div class="home-block-view-all">
<a class="home-block-view-all-link" href="/packages?sort=popularity" rel="nofollow" title="Search popular packages" data-ga-click-event="landing-most-popular-view-all">View all</a>
<a class="home-block-view-all-link" href="/packages?sort=downloads" rel="nofollow" title="Search popular packages" data-ga-click-event="landing-most-popular-view-all">View all</a>
</div>
</div>
</div>
Expand Down
13 changes: 7 additions & 6 deletions app/test/search/mem_index_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ void main() {
'runtime:web'
],
likeCount: 10,
popularityScore: 0.7,
downloadScore: 0.7,
downloadCount: 70,
grantedPoints: 110,
maxPoints: 110,
dependencies: {'async': 'direct', 'test': 'dev', 'foo': 'transitive'},
Expand Down Expand Up @@ -64,8 +64,8 @@ The delegating wrapper classes allow users to easily add functionality on top of
grantedPoints: 10,
maxPoints: 110,
dependencies: {'test': 'dev'},
popularityScore: 0.8,
downloadScore: 0.8,
downloadCount: 80,
),
PackageDocument(
package: 'chrome_net',
Expand All @@ -81,6 +81,7 @@ server.dart adds a small, prescriptive server (PicoServer) that can be configure
grantedPoints: 0,
maxPoints: 110,
downloadScore: 0.0,
downloadCount: 0,
),
];
lastPackageUpdated =
Expand Down Expand Up @@ -280,16 +281,16 @@ server.dart adds a small, prescriptive server (PicoServer) that can be configure
});
});

test('order by popularity', () async {
test('order by downloads', () async {
final PackageSearchResult result =
index.search(ServiceSearchQuery.parse(order: SearchOrder.popularity));
index.search(ServiceSearchQuery.parse(order: SearchOrder.downloads));
expect(json.decode(json.encode(result)), {
'timestamp': isNotNull,
'totalCount': 3,
'sdkLibraryHits': [],
'packageHits': [
{'package': 'async', 'score': 0.8},
{'package': 'http', 'score': 0.7},
{'package': 'async', 'score': 80},
{'package': 'http', 'score': 70},
{'package': 'chrome_net', 'score': 0.0},
],
});
Expand Down
11 changes: 6 additions & 5 deletions app/test/search/result_combiner_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ void main() {
readme: 'Many useful string methods like substring.',
grantedPoints: 110,
maxPoints: 110,
popularityScore: 0.4,
downloadScore: 0.4,
downloadCount: 4,
),
],
);
Expand Down Expand Up @@ -78,13 +79,13 @@ void main() {

test('non-text ranking', () async {
final results = combiner
.search(ServiceSearchQuery.parse(order: SearchOrder.popularity));
.search(ServiceSearchQuery.parse(order: SearchOrder.downloads));
expect(json.decode(json.encode(results.toJson())), {
'timestamp': isNotNull,
'totalCount': 1,
'sdkLibraryHits': [],
'packageHits': [
{'package': 'stringutils', 'score': 0.4},
{'package': 'stringutils', 'score': 4},
],
});
});
Expand All @@ -97,7 +98,7 @@ void main() {
'totalCount': 1,
'sdkLibraryHits': [],
'packageHits': [
{'package': 'stringutils', 'score': closeTo(1.0, 0.01)},
{'package': 'stringutils', 'score': closeTo(0.85, 0.01)},
],
});
});
Expand All @@ -124,7 +125,7 @@ void main() {
},
],
'packageHits': [
{'package': 'stringutils', 'score': closeTo(0.73, 0.01)}
{'package': 'stringutils', 'score': closeTo(0.67, 0.01)}
],
});
});
Expand Down
6 changes: 5 additions & 1 deletion pkg/_pub_shared/lib/search/search_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ int extractPageFromUrlParameters(Map<String, String> queryParameters) {

/// How search results should be ordered.
enum SearchOrder {
/// Search score should be a weighted value of [text], [popularity], [points]
/// Search score should be a weighted value of [text], [downloads], [points]
/// and [like], ordered decreasing.
top,

Expand All @@ -50,6 +50,10 @@ enum SearchOrder {
updated,

/// Search order should be in decreasing popularity score.
/// WARNING: The value shouldn't be used anymore.
///
/// TODO: remove in a future release.
@Deprecated('Popularity is no longer used.')
popularity,

/// Search order should be in decreasing download counts.
Expand Down
Loading