Skip to content

Commit

Permalink
Update all popularity when updating the search snapshot. (#7169)
Browse files Browse the repository at this point in the history
  • Loading branch information
isoos authored Nov 9, 2023
1 parent e0de45e commit 329339d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions app/lib/search/backend.dart
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,15 @@ class SearchBackend {
futures.clear();

if (claim.valid && lastUploadedSnapshotTimestamp != snapshot.updated) {
// Updates the normalized like score across all the packages.
snapshot.updateLikeScores();

// Updates all popularity values to the currently cached one, otherwise
// only updated package would have been on their new values.
for (final d in snapshot.documents!.values) {
d.popularityScore = popularityStorage.lookup(d.package);
}

await _snapshotStorage.uploadDataAsJsonMap(snapshot.toJson());
lastUploadedSnapshotTimestamp = snapshot.updated!;
}
Expand Down
2 changes: 1 addition & 1 deletion app/lib/search/search_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class PackageDocument {
double? likeScore;

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

final int grantedPoints;
final int maxPoints;
Expand Down

0 comments on commit 329339d

Please sign in to comment.