add limit on interesting people

This commit is contained in:
Adolfo Reyna
2022-09-06 21:57:30 -04:00
parent ac3b7da016
commit 139f4ab086

View File

@@ -93,7 +93,7 @@ userDB = (DB) => {
});
}
DB.getFriendsFriends = async (profileId) => {
DB.getFriendsFriends = async (profileId, limit = 10) => {
const profile = await DB.getProfile(profileId);
if(!profile) return [];
let ids = profile.following.map((id)=>DB.ObjectID(id));
@@ -102,7 +102,7 @@ userDB = (DB) => {
profile.following.forEach(id => {
if(!alreadyFollowingMap[id]) alreadyFollowingMap[id] = 1;
})
return DB.profileCols.find({_id:{$in: ids}}).project({following: 1}).toArray().then(profiles => {
return DB.profileCols.find({_id:{$in: ids}}).project({following: 1}).limit(limit).toArray().then(profiles => {
let friendsOfFriendsMap = {};
profiles.forEach(p => {
p.following.forEach(followingId => {