mirror of
https://github.com/ClaytonWWilson/CS307-Team24.git
synced 2025-12-17 02:38:47 +00:00
Modified code structure for filter posts
This commit is contained in:
parent
4d4b085a2b
commit
b9ca0dc492
@ -73,33 +73,31 @@ exports.getFollowedPosts = (req, res) => {
|
|||||||
followers_list.get()
|
followers_list.get()
|
||||||
.then(function(allFollowers) {
|
.then(function(allFollowers) {
|
||||||
allFollowers.forEach(function(followers) {
|
allFollowers.forEach(function(followers) {
|
||||||
followers_str.push(followers.data().handle);
|
post_query.get()
|
||||||
});
|
.then(function(allPosts) {
|
||||||
|
let posts = [];
|
||||||
post_query.get()
|
allPosts.forEach(function(doc) {
|
||||||
.then(function(allPosts) {
|
if(doc.data().userHandle === "qwertyuiop") {
|
||||||
let posts = [];
|
if(doc.data().microBlogTopics.includes("purdue")) {
|
||||||
allPosts.forEach(function(doc) {
|
posts.push(doc.data());
|
||||||
if(followers_str.includes(doc.data().userHandle)) {
|
}
|
||||||
if(doc.data().microBlogTopics.includes("purdue") || doc.data().microBlogTopics.includes("2077")) {
|
|
||||||
posts.push(doc.data());
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
/*posts.sort(function(a, b) {
|
||||||
|
return b.createdAt - a.createdAt;
|
||||||
|
});*/
|
||||||
|
return res.status(200).json(posts);
|
||||||
|
})
|
||||||
|
.catch(function(err) {
|
||||||
|
res.status(500).send("Failed to retrieve any post.", err);
|
||||||
});
|
});
|
||||||
/*posts.sort(function(a, b) {
|
|
||||||
return b.createdAt - a.createdAt;
|
|
||||||
});*/
|
|
||||||
return res.status(200).json(posts);
|
|
||||||
})
|
|
||||||
.catch(function(err) {
|
|
||||||
res.status(500).send("Failed to retrieve posts.", err);
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.then(function() {
|
.then(function() {
|
||||||
//res.status(200).send("Successfully retrieved all posts from followed users.");
|
//res.status(200).send("Successfully retrieved all interesting posts from followed users.");
|
||||||
return;
|
return;
|
||||||
})
|
})
|
||||||
.catch(function(err) {
|
.catch(function(err) {
|
||||||
res.status(500).send("Failed to retrieve follower handles.", err);
|
res.status(500).send("Failed to retrieve any post.", err);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user