mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-29 18:16:17 +01:00
notification fixes
made post notifications unique per post so they dont overwrite other types.
This commit is contained in:
@@ -170,7 +170,32 @@ module.exports = function(db, module) {
|
||||
};
|
||||
|
||||
module.sortedSetsCard = function(keys, callback) {
|
||||
async.map(keys, module.sortedSetCard, callback);
|
||||
var pipeline = [
|
||||
{ $match : { _key : { $in: keys } } } ,
|
||||
{ $group: { _id: {_key: '$_key'}, count: { $sum: 1 } } },
|
||||
{ $project: { _id: 1, count: '$count' } }
|
||||
];
|
||||
db.collection('objects').aggregate(pipeline, function(err, results) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
if (!Array.isArray(results)) {
|
||||
results = [];
|
||||
}
|
||||
|
||||
var map = {};
|
||||
results.forEach(function(item) {
|
||||
if (item && item._id._key) {
|
||||
map[item._id._key] = item.count;
|
||||
}
|
||||
});
|
||||
|
||||
results = keys.map(function(key) {
|
||||
return map[key] || 0;
|
||||
});
|
||||
callback(null, results);
|
||||
});
|
||||
};
|
||||
|
||||
module.sortedSetRank = function(key, value, callback) {
|
||||
|
||||
Reference in New Issue
Block a user