Jdlrobson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/346616 )

Change subject: Simplify storage to be compatible with wikipedia-edit-scorer
......................................................................

Simplify storage to be compatible with wikipedia-edit-scorer

wikipedia-edit-scorer expects a distribution of usernames in the format
{ name: 3, name2: 4 } where the key is the username and the value
the number of edits by that user. We were passing something different
to the edit scorer which meant that the getBias method of the scorer
always returned NaN so wasn't influencing the score.

This rectifies this, adding a test to check format.

Change-Id: I7d1aeb7e9bb706e48004bc0c65f2e0b9b59fa2a7
---
M lib/EventProcessor.js
M test/features/lib/EventProcessor.js
2 files changed, 7 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/trending-edits 
refs/changes/16/346616/1

diff --git a/lib/EventProcessor.js b/lib/EventProcessor.js
index 95d9e40..5634d5f 100644
--- a/lib/EventProcessor.js
+++ b/lib/EventProcessor.js
@@ -138,11 +138,9 @@
             }
             if (!contributors.names[username]) {
                 contributors.total++;
-                contributors.names[username] = {
-                    edits: 1
-                };
+                contributors.names[username] = 1;
             } else {
-                contributors.names[username].edits++;
+                contributors.names[username]++;
             }
             page.bytes = edit.rev_len - page.rev_len;
             if (isRevert(edit)) {
diff --git a/test/features/lib/EventProcessor.js 
b/test/features/lib/EventProcessor.js
index 2a33c6a..b01462f 100644
--- a/test/features/lib/EventProcessor.js
+++ b/test/features/lib/EventProcessor.js
@@ -1,6 +1,7 @@
 'use strict';
 
 var assert = require('../../utils/assert.js');
+var scorer = require('wikipedia-edits-scorer');
 var EventProcessor = require('../../../lib/EventProcessor.js');
 
 const ADMIN = {
@@ -96,9 +97,11 @@
         var pages = processor.getPages();
         assert.ok( pages[0].contributors.total === 4, 'Total unique editors is 
tallied up.' );
         assert.ok( pages[0].contributors.anons === 2, 'Total unique anon edits 
is tallied up.' );
-        assert.ok( pages[0].contributors.names.Jon.edits === 2, 'Edits by Jon 
counted' );
-        assert.ok( pages[0].contributors.names['127.0.0.5'].edits === 1, 
'Edits by anon counted' );
+        assert.ok( pages[0].contributors.names.Jon === 2, 'Edits by Jon 
counted' );
+        assert.ok( pages[0].contributors.names['127.0.0.5'] === 1, 'Edits by 
anon counted' );
         assert.ok( pages[0].isNew === false, 'False isNew flag for pages with 
parent id' );
+        assert.ok( !isNaN(scorer.getBias(pages[0].contributors.names)),
+            'Check the names are stored in the suitable format compatible with 
wikipedia-edit-scorer.' );
     });
 
     it('counts the number of anonymous edits', function() {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7d1aeb7e9bb706e48004bc0c65f2e0b9b59fa2a7
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

Reply via email to