Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 4 additions & 3 deletions app/lib/search/mem_index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,10 @@ class InMemoryPackageIndex {
_adjustedOverallScores = _documents.map((doc) {
final downloadScore = doc.downloadScore ?? 0.0;
final likeScore = doc.likeScore ?? 0.0;
final combinedScore = (downloadScore + likeScore) / 2;
final points = doc.grantedPoints / math.max(1, doc.maxPoints);
final overall = combinedScore * 0.5 + points * 0.5;
final popularityScore = (downloadScore + likeScore) / 2;
final pointScore =
math.sqrt(doc.grantedPoints / math.max(1, doc.maxPoints));
final overall = popularityScore * 0.5 + pointScore * 0.5;
doc.overallScore = overall;
// adding a base score prevents later multiplication with zero
return 0.4 + 0.6 * overall;
Expand Down
12 changes: 6 additions & 6 deletions app/test/search/mem_index_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ server.dart adds a small, prescriptive server (PicoServer) that can be configure
'nameMatches': ['async'],
'sdkLibraryHits': [],
'packageHits': [
{'package': 'async', 'score': closeTo(0.65, 0.01)},
{'package': 'async', 'score': closeTo(0.71, 0.01)},
],
});
});
Expand Down Expand Up @@ -143,8 +143,8 @@ server.dart adds a small, prescriptive server (PicoServer) that can be configure
'totalCount': 2,
'sdkLibraryHits': [],
'packageHits': [
{'package': 'async', 'score': closeTo(0.71, 0.01)},
{'package': 'http', 'score': closeTo(0.69, 0.01)},
{'package': 'async', 'score': closeTo(0.65, 0.01)},
],
});
});
Expand All @@ -157,7 +157,7 @@ server.dart adds a small, prescriptive server (PicoServer) that can be configure
'totalCount': 1,
'sdkLibraryHits': [],
'packageHits': [
{'package': 'async', 'score': closeTo(0.34, 0.01)},
{'package': 'async', 'score': closeTo(0.37, 0.01)},
],
});
});
Expand All @@ -183,7 +183,7 @@ server.dart adds a small, prescriptive server (PicoServer) that can be configure
'totalCount': 1,
'sdkLibraryHits': [],
'packageHits': [
{'package': 'async', 'score': closeTo(0.24, 0.01)},
{'package': 'async', 'score': closeTo(0.26, 0.01)},
],
});
});
Expand Down Expand Up @@ -335,7 +335,7 @@ server.dart adds a small, prescriptive server (PicoServer) that can be configure
'sdkLibraryHits': [],
'packageHits': [
{'package': 'http', 'score': closeTo(0.92, 0.01)},
{'package': 'async', 'score': closeTo(0.41, 0.01)},
{'package': 'async', 'score': closeTo(0.52, 0.01)},
],
});

Expand Down Expand Up @@ -422,7 +422,7 @@ server.dart adds a small, prescriptive server (PicoServer) that can be configure
'totalCount': 1,
'sdkLibraryHits': [],
'packageHits': [
{'package': 'async', 'score': closeTo(0.41, 0.01)},
{'package': 'async', 'score': closeTo(0.52, 0.01)},
],
});

Expand Down
Loading