From ed7c9348b77d9c5731ca31445f5b09625276359a Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Mon, 28 Oct 2013 13:45:32 -0400 Subject: [PATCH] interim commit --- src/notifications.js | 50 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 9 deletions(-) diff --git a/src/notifications.js b/src/notifications.js index fe92a1c9ed..4ff52af1a8 100644 --- a/src/notifications.js +++ b/src/notifications.js @@ -132,16 +132,48 @@ var RDB = require('./redis.js'), var cutoffTime = cutoff.getTime(); - RDB.smembers('notifications', function(err, nids) { - async.filter(nids, function(nid, next) { - RDB.hget('notifications:' + nid, 'datetime', function(err, datetime) { - if (parseInt(datetime, 10) < cutoffTime) next(true); - else next(false); + async.parallel({ + "inboxes": function(next) { + RDB.keys('uid:*:notifications:unread', next); + }, + "nids": function(next) { + RDB.smembers('notifications', function(err, nids) { + async.filter(nids, function(nid, next) { + RDB.hget('notifications:' + nid, 'datetime', function(err, datetime) { + if (parseInt(datetime, 10) < cutoffTime) next(true); + else next(false); + }); + }, function(expiredNids) { + next(null, expiredNids); + }); }); - }, function(expiredNids) { - console.log(expiredNids); - }); - }); + } + }, function(err, results) { + if (!err) { + var numInboxes = results.inboxes.length, + x; + + async.each(results.nids, function(nid, next) { + var multi = RDB.multi(); + + for(x=0;x