diff options
author | Niv Sardi <xaiki@evilgiggle.com> | 2014-04-28 21:54:21 -0300 |
---|---|---|
committer | Niv Sardi <xaiki@evilgiggle.com> | 2014-04-28 21:54:21 -0300 |
commit | ce23a6534d4ccb289db711b22a1734fb8fab8673 (patch) | |
tree | f929681b4532a5d6f55f39550573dac686ab1b5a | |
parent | 578751883b6476cda6541014c33a57878a6f2369 (diff) | |
download | popcorn-api-origin/xaiki/cache.zip popcorn-api-origin/xaiki/cache.tar.gz popcorn-api-origin/xaiki/cache.tar.bz2 |
cache all shows instead of querrying the DB all the timeorigin/xaiki/cache
Signed-off-by: Niv Sardi <xaiki@evilgiggle.com>
-rwxr-xr-x | app.js | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -21,6 +21,7 @@ var TTL = 1000 * 60 * 60 * 24; * EXTRACT FUNCTIONS */ +var cache = {shows: {error: 'still loading'}}; function extractShowInfo(show, callback) { @@ -166,8 +167,11 @@ function refreshDatabase() { }); }, function (error) { if(error) return console.error(error); - async.mapSeries(allShows[0], extractTrakt, function(err, results){ - + async.mapLimit(allShows[0], 64, extractTrakt, function(err, results){ + db.tvshows.find({num_seasons: { $gt: 0 }}).sort({ year: -1 }).exec(function (err, docs) { + console.log ('updating cache'); + cache.shows = docs; + }); }); }); } |