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

Unified Diff: components/ntp_snippets/category_rankers/click_based_category_ranker.cc

Issue 2612773003: [NTP::SectionOrder] Make dismissed category penalty a variation param. (Closed)
Patch Set: jkrcal@ comment. Created 3 years, 11 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 | components/ntp_snippets/category_rankers/click_based_category_ranker_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/ntp_snippets/category_rankers/click_based_category_ranker.cc
diff --git a/components/ntp_snippets/category_rankers/click_based_category_ranker.cc b/components/ntp_snippets/category_rankers/click_based_category_ranker.cc
index 3fe59a8415555299695ead960f04ec783909bc78..8b782791a6de7bce3aeceab0f396b2baf8f8a717 100644
--- a/components/ntp_snippets/category_rankers/click_based_category_ranker.cc
+++ b/components/ntp_snippets/category_rankers/click_based_category_ranker.cc
@@ -9,9 +9,11 @@
#include "base/memory/ptr_util.h"
#include "base/values.h"
#include "components/ntp_snippets/category_rankers/constant_category_ranker.h"
+#include "components/ntp_snippets/features.h"
#include "components/ntp_snippets/pref_names.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
+#include "components/variations/variations_associated_data.h"
namespace ntp_snippets {
@@ -56,11 +58,19 @@ const int kDecayFactorNumerator = 91;
const int kDecayFactorDenominator = 100; // pow(0.91, 7) = 0.517
// Number of positions by which a dismissed category is downgraded.
-const int kDismissedCategoryPenalty = 1;
+const int kDefaultDismissedCategoryPenalty = 1;
+const char* kDismissedCategoryPenaltyParamName =
+ "click_based_category_ranker-dismissed_category_penalty";
const char kCategoryIdKey[] = "category";
const char kClicksKey[] = "clicks";
+int GetDismissedCategoryPenaltyVariationValue() {
+ return variations::GetVariationParamByFeatureAsInt(
+ kCategoryRanker, kDismissedCategoryPenaltyParamName,
+ kDefaultDismissedCategoryPenalty);
+}
+
} // namespace
ClickBasedCategoryRanker::ClickBasedCategoryRanker(
@@ -188,8 +198,14 @@ void ClickBasedCategoryRanker::OnCategoryDismissed(Category category) {
return;
}
+ const int penalty = GetDismissedCategoryPenaltyVariationValue();
+ if (penalty == 0) {
+ // The dismissed category penalty is turned off, the call is ignored.
+ return;
+ }
+
std::vector<RankedCategory>::iterator current = FindCategory(category);
- for (int downgrade = 0; downgrade < kDismissedCategoryPenalty; ++downgrade) {
+ for (int downgrade = 0; downgrade < penalty; ++downgrade) {
std::vector<RankedCategory>::iterator next = current + 1;
if (next == ordered_categories_.end()) {
break;
@@ -232,7 +248,7 @@ int ClickBasedCategoryRanker::GetNumTopCategoriesWithExtraMargin() {
// static
int ClickBasedCategoryRanker::GetDismissedCategoryPenalty() {
- return kDismissedCategoryPenalty;
+ return GetDismissedCategoryPenaltyVariationValue();
}
ClickBasedCategoryRanker::RankedCategory::RankedCategory(Category category,
« no previous file with comments | « no previous file | components/ntp_snippets/category_rankers/click_based_category_ranker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698