Skip to content
This repository has been archived by the owner on Mar 3, 2021. It is now read-only.

Commit

Permalink
Providing utility script to bulk update all episodes
Browse files Browse the repository at this point in the history
This helps in part with #52.
  • Loading branch information
dariusk committed Nov 8, 2017
1 parent 2404fae commit eaf0266
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions server/update-all-episodes.js
Original file line number Diff line number Diff line change
@@ -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);
});
});

0 comments on commit eaf0266

Please sign in to comment.