From 581b15da6900a58b1f1f62803c3e69e9c5201418 Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Thu, 19 Apr 2018 19:21:05 +0200 Subject: [PATCH] Cron job for checking mediawiki changes --- integrations/mediawiki.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/integrations/mediawiki.js b/integrations/mediawiki.js index 77723b4..e86c5c8 100644 --- a/integrations/mediawiki.js +++ b/integrations/mediawiki.js @@ -1,6 +1,7 @@ const util = require('util'); const fetch = require('node-fetch'); const groupArray = require('group-array'); +const cron = require('node-cron'); module.exports = async function(robot, kredits) { @@ -165,9 +166,13 @@ module.exports = async function(robot, kredits) { robot.brain.set('kredits:mediawiki:last_processed_at', new Date().toISOString()); } - fetchChanges() - .then(res => groupChangesByUser(res)) - .then(res => createProposals(res)) - .then(() => updateTimestampForNextFetch()); + function processWikiChangesSinceLastRun () { + fetchChanges() + .then(res => groupChangesByUser(res)) + .then(res => createProposals(res)) + .then(() => updateTimestampForNextFetch()); + } + + cron.schedule('* 7 * * *', processWikiChangesSinceLastRun); };