summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiv Sardi <xaiki@evilgiggle.com>2014-04-28 21:54:21 -0300
committerNiv Sardi <xaiki@evilgiggle.com>2014-04-28 21:54:21 -0300
commitce23a6534d4ccb289db711b22a1734fb8fab8673 (patch)
treef929681b4532a5d6f55f39550573dac686ab1b5a
parent578751883b6476cda6541014c33a57878a6f2369 (diff)
downloadpopcorn-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-xapp.js8
1 files changed, 6 insertions, 2 deletions
diff --git a/app.js b/app.js
index 490a7f9..a34f980 100755
--- a/app.js
+++ b/app.js
@@ -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;
+ });
});
});
}