From f68f7965829a8abd77e48c4bef11afa9e080d7ae Mon Sep 17 00:00:00 2001 From: Will Murphy Date: Wed, 20 Jan 2021 22:19:03 -0600 Subject: [PATCH] fix non-updating top groups --- routes/user.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/routes/user.js b/routes/user.js index 0000481..abeb7ef 100644 --- a/routes/user.js +++ b/routes/user.js @@ -9,6 +9,7 @@ router.get('/', net.validators.jsonld, function (req, res) { const db = req.app.get('db') db.collection('streams') .aggregate([ + { $sort: { _id: -1 } }, // start from most recent { $limit: 10000 }, // don't traverse the entire history { $match: { type: 'Announce' } }, { $group: { _id: '$actor', postCount: { $sum: 1 } } }, @@ -18,7 +19,7 @@ router.get('/', net.validators.jsonld, function (req, res) { { $project: { _id: 0, _meta: 0, actor: 0 } } ]) .sort({ postCount: -1 }) - .limit(Number.parseInt(req.query.n) || 20) + .limit(Number.parseInt(req.query.n) || 50) .toArray() .then(groups => { console.log(JSON.stringify(groups)); return groups }) .then(groups => res.json(groups))