Skip to content

Commit

Permalink
replace 2 magic values with constants, make a request start right ins…
Browse files Browse the repository at this point in the history
…tead of waiting 60 seconds
  • Loading branch information
adamsullovey committed Feb 15, 2015
1 parent 6918962 commit 7794a47
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions scraper.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ var parseString = require('xml2js').parseString,
http = require('q-io/http'),
crypto = require('crypto');

const REFRESH_INTERVAL = 60000,
FEED_URL = 'https://secure.whistlerblackcomb.com/ls/lifts.aspx';

// load the feed
var makeRequest = function () {

var saveToElasticSearchPromises = http.read('https://secure.whistlerblackcomb.com/ls/lifts.aspx')
var saveToElasticSearchPromises = http.read(FEED_URL)
.then(onStatusLoaded)
.then(onXmlParse);

Expand Down Expand Up @@ -93,7 +96,8 @@ var onDataSaved = function (response) {
};


//makeRequest();
// make 1 request right away
makeRequest();

// start a timer to load feed every once in a while
setInterval(makeRequest, 60000);
setInterval(makeRequest, REFRESH_INTERVAL);

0 comments on commit 7794a47

Please sign in to comment.