add limit on interesting people
This commit is contained in:
@@ -93,7 +93,7 @@ userDB = (DB) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
DB.getFriendsFriends = async (profileId) => {
|
DB.getFriendsFriends = async (profileId, limit = 10) => {
|
||||||
const profile = await DB.getProfile(profileId);
|
const profile = await DB.getProfile(profileId);
|
||||||
if(!profile) return [];
|
if(!profile) return [];
|
||||||
let ids = profile.following.map((id)=>DB.ObjectID(id));
|
let ids = profile.following.map((id)=>DB.ObjectID(id));
|
||||||
@@ -102,7 +102,7 @@ userDB = (DB) => {
|
|||||||
profile.following.forEach(id => {
|
profile.following.forEach(id => {
|
||||||
if(!alreadyFollowingMap[id]) alreadyFollowingMap[id] = 1;
|
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 = {};
|
let friendsOfFriendsMap = {};
|
||||||
profiles.forEach(p => {
|
profiles.forEach(p => {
|
||||||
p.following.forEach(followingId => {
|
p.following.forEach(followingId => {
|
||||||
|
|||||||
Reference in New Issue
Block a user