jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/341361 )

Change subject: Decay based on period parameter
......................................................................


Decay based on period parameter

Currently the decay is hard coded to 1.5hrs. This means for results
in a 24 hour period, anything that has occurred within the last 1.5hrs
will be weighted much higher.

To avoid this we should tie the decay to the period we are measuring for.

Bug: T156680
Change-Id: I55ab3ec695c127323b26326f0bad98e47e049121
---
M lib/score-pages.js
M routes/trending-v1.js
2 files changed, 5 insertions(+), 5 deletions(-)

Approvals:
  Mobrovac: Looks good to me, approved
  Ppchelko: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/lib/score-pages.js b/lib/score-pages.js
index adde783..0c0e842 100644
--- a/lib/score-pages.js
+++ b/lib/score-pages.js
@@ -6,12 +6,12 @@
  * Score and sort pages
  * @param {Date} date
  * @param {Array} pages
+ * @param {Number} [halflife] greater than 0, which causes scores to decay 
over time.
+ *   Will default to 1.5 if none given.
  * @return {Array}
  */
-function scoreAndSortPages(date, pages) {
-    // scorer takes a decay in hours (1.5 hrs) which causes scores to decay 
over time.
-    // We can decrease this value if we find the results are not fresh enough
-    var halflife = 1.5;
+function scoreAndSortPages(date, pages, halflife) {
+    halflife = halflife || 1.5;
 
     pages.forEach(function(candidate) {
         var contrs = candidate.contributors;
diff --git a/routes/trending-v1.js b/routes/trending-v1.js
index 46bcb9f..39289d1 100644
--- a/routes/trending-v1.js
+++ b/routes/trending-v1.js
@@ -66,7 +66,7 @@
         const data = {
             timestamp: date,
             // show the 20 scored top pages being edited
-            pages: scorePages(date, filterPages(processor.getPages(), 
conf)).slice(0, conf.max_results)
+            pages: scorePages(date, filterPages(processor.getPages(), conf), 
period).slice(0, conf.max_results)
                 .map(function(page) {
                     return {
                         totalEdits: page.edits,

-- 
To view, visit https://gerrit.wikimedia.org/r/341361
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I55ab3ec695c127323b26326f0bad98e47e049121
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/services/trending-edits
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: BearND <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: Mobrovac <[email protected]>
Gerrit-Reviewer: Ppchelko <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to