Jdlrobson has uploaded a new change for review. (
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, 4 insertions(+), 5 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/trending-edits
refs/changes/61/341361/1
diff --git a/lib/score-pages.js b/lib/score-pages.js
index adde783..3460a18 100644
--- a/lib/score-pages.js
+++ b/lib/score-pages.js
@@ -6,12 +6,11 @@
* Score and sort pages
* @param {Date} date
* @param {Array} pages
+ * @param {Number} [decayPeriod] greater than 0, which causes scores to decay
over time.
* @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, decayPeriod) {
+ var halflife = period || 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: newchange
Gerrit-Change-Id: I55ab3ec695c127323b26326f0bad98e47e049121
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/trending-edits
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits