From fca991c6850cc4e78e68fe63afd5f9257b10683d Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Sat, 13 Apr 2019 14:18:47 +0100 Subject: [PATCH] Add date to mediawiki edits Use the day before, as we collect them at 7am every day. --- integrations/mediawiki.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/integrations/mediawiki.js b/integrations/mediawiki.js index b814120..8e6fcc6 100644 --- a/integrations/mediawiki.js +++ b/integrations/mediawiki.js @@ -33,14 +33,15 @@ module.exports = async function(robot, kredits) { }); } - function createContribution(username, amount, description, url, details={}) { + function createContribution(username, date, amount, description, url, details={}) { return getContributorByWikiUser(username).then(contributor => { robot.logger.debug(`[hubot-kredits] Creating contribution token for ${amount}₭S to ${contributor.name} for ${url}...`); let contribution = { contributorId: contributor.id, - amount: amount, contributorIpfsHash: contributor.ipfsHash, + date, + amount: amount, url, description, details, @@ -141,6 +142,10 @@ module.exports = async function(robot, kredits) { } function createContributionForUserChanges (user, changes) { + const dateNow = new Date(); + const dateYesterday = dateNow.setDate(dateNow.getDate() - 1); + const date = (new Date(dateYesterday)).toISOString().split('T')[0]; + const details = analyzeUserChanges(user, changes); const amount = calculateAmountForChanges(details); @@ -161,7 +166,7 @@ module.exports = async function(robot, kredits) { url = `${wikiURL}index.php?title=${rc.title}&diff=${rc.revid}&oldid=${rc.old_revid}`; } - return createContribution(user, amount, desc, url, details); + return createContribution(user, date, amount, desc, url, details); } function updateTimestampForNextFetch () {