Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(414)

Unified Diff: ui/app_list/search/mixer.cc

Issue 906133003: app_list search results relevance scores are clamped to [0, 1] range. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@applist-mixer-knownresult-test
Patch Set: Rebase. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/app_list/search/mixer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/app_list/search/mixer.cc
diff --git a/ui/app_list/search/mixer.cc b/ui/app_list/search/mixer.cc
index 69aef728478b6ec49a1ba21149f1b559edf61913..a78932f1481f9df83259394b1e50b16cf0e5ee93 100644
--- a/ui/app_list/search/mixer.cc
+++ b/ui/app_list/search/mixer.cc
@@ -62,10 +62,13 @@ class Mixer::Group {
for (const SearchProvider* provider : providers_) {
for (SearchResult* result : provider->results()) {
- DCHECK_GE(result->relevance(), 0.0);
- DCHECK_LE(result->relevance(), 1.0);
DCHECK(!result->id().empty());
+ // We cannot rely on providers to give relevance scores in the range
+ // [0.0, 1.0] (e.g., PeopleProvider directly gives values from the
+ // Google+ API). Clamp to that range.
+ double relevance = std::min(std::max(result->relevance(), 0.0), 1.0);
+
double boost = boost_;
KnownResults::const_iterator known_it =
known_results.find(result->id());
@@ -93,7 +96,7 @@ class Mixer::Group {
if (is_voice_query && result->voice_result())
boost += 4.0;
- results_.push_back(SortData(result, result->relevance() + boost));
+ results_.push_back(SortData(result, relevance + boost));
}
}
« no previous file with comments | « no previous file | ui/app_list/search/mixer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698