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

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

Issue 2668063004: [NTP::SectionOrder] Track category index after it has been moved up. (Closed)
Patch Set: tschumann@ 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 9965ab71ca87552490c92eb7775aa17668272206..81b8ec0028f2354bde9daef6078e7c8da0835c49 100644
--- a/components/ntp_snippets/category_rankers/click_based_category_ranker.cc
+++ b/components/ntp_snippets/category_rankers/click_based_category_ranker.cc
@@ -12,6 +12,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/values.h"
#include "components/ntp_snippets/category_rankers/constant_category_ranker.h"
+#include "components/ntp_snippets/content_suggestions_metrics.h"
#include "components/ntp_snippets/features.h"
#include "components/ntp_snippets/pref_names.h"
#include "components/prefs/pref_registry_simple.h"
@@ -229,6 +230,8 @@ void ClickBasedCategoryRanker::OnSuggestionOpened(Category category) {
std::vector<RankedCategory>::iterator previous = current - 1;
const int passing_margin = GetPositionPassingMargin(previous);
if (current->clicks >= previous->clicks + passing_margin) {
+ const int new_index = previous - ordered_categories_.begin();
+ ntp_snippets::metrics::OnCategoryMovedUp(new_index);
// It is intended to move only by one position per click in order to avoid
// dramatic changes, which could confuse the user.
std::swap(*current, *previous);
« 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