From eaf0266c5819e454de07f72b2f5952674283b108 Mon Sep 17 00:00:00 2001 From: Darius Kazemi Date: Wed, 8 Nov 2017 19:10:02 +0000 Subject: [PATCH] Providing utility script to bulk update all episodes This helps in part with #52. --- server/update-all-episodes.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 server/update-all-episodes.js diff --git a/server/update-all-episodes.js b/server/update-all-episodes.js new file mode 100644 index 0000000..960e0ca --- /dev/null +++ b/server/update-all-episodes.js @@ -0,0 +1,20 @@ +'use strict'; + +require('dotenv').config(); +const request = require('request'); +const async = require('async'); + +request(process.env.DATA_BUCKET+'episodes.json', (err, req, body) => { + let episodes = JSON.parse(body) + .map(episode => `http://localhost:3000/api/${process.env.API_HASH}/update/${episode.number}`); + console.log(`Updating ${episodes.length} episodes. This might take ${0.5*episodes.length} minutes.`); + async.mapSeries(episodes, function(url, callback) { + console.log('sending GET request to', url); + request(url, function(error, response, body) { + callback(error, body); + }); + }, function(err, results) { + console.log(err); + console.log('Done updating all episodes.', results); + }); +});