Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/utils.js

Issue 29562595: Issue 2824 - Only consider ads subscriptions in chooseFilterSubscription (Closed)
Patch Set: Created Oct. 2, 2017, 10:18 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« lib/subscriptionInit.js ('K') | « lib/subscriptionInit.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/utils.js
diff --git a/lib/utils.js b/lib/utils.js
index e218dab6258ccbecc283e62c3d27c155cf973774..48e1f1fe3813435aef537cea77e95083e94c6018 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -79,46 +79,6 @@ let Utils = exports.Utils = {
return null;
},
- chooseFilterSubscription(subscriptions)
- {
- let selectedItem = null;
- let selectedPrefix = null;
- let matchCount = 0;
- for (let subscription of subscriptions)
- {
- if (!selectedItem)
- selectedItem = subscription;
-
- let prefix = Utils.checkLocalePrefixMatch(
- subscription.getAttribute("prefixes")
- );
- if (prefix)
- {
- if (!selectedPrefix || selectedPrefix.length < prefix.length)
- {
- selectedItem = subscription;
- selectedPrefix = prefix;
- matchCount = 1;
- }
- else if (selectedPrefix && selectedPrefix.length == prefix.length)
- {
- matchCount++;
-
- // If multiple items have a matching prefix of the same length:
- // Select one of the items randomly, probability should be the same
- // for all items. So we replace the previous match here with
- // probability 1/N (N being the number of matches).
- if (Math.random() * matchCount < 1)
- {
- selectedItem = subscription;
- selectedPrefix = prefix;
- }
- }
- }
- }
- return selectedItem;
- },
-
getDocLink(linkID)
{
let docLink = require("prefs").Prefs.documentation_link;
« lib/subscriptionInit.js ('K') | « lib/subscriptionInit.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld