Reading index file and ignoring already indexed content.
This commit is contained in:
@@ -60,16 +60,18 @@ function curatePost(accUserPosts, post, user, index, processed, args) {
|
||||
subreddit: post.subreddit.display_name,
|
||||
preview: post.preview ? post.preview.images.map(image => image.source) : null,
|
||||
host,
|
||||
hash: hashPost(post)
|
||||
hash: hashPost(post),
|
||||
});
|
||||
}
|
||||
|
||||
const curatePosts = (userPosts, args) => {
|
||||
const processed = new Set();
|
||||
const curatePosts = (userPosts, args) => Object.values(userPosts).reduce((accPosts, user) => {
|
||||
const indexedHostIds = user.indexed.map(entry => entry.hostId); // already downloaded
|
||||
const processed = new Set(indexedHostIds);
|
||||
|
||||
return Object.values(userPosts).reduce((accPosts, user) => {
|
||||
return { ...accPosts, [user.name]: { ...user, posts: user.posts.reduce((accUserPosts, post, index) => curatePost(accUserPosts, post, user, index, processed, args), []) } };
|
||||
}, {});
|
||||
};
|
||||
const posts = user.posts.reduce((accUserPosts, post, index) =>
|
||||
curatePost(accUserPosts, post, user, index, processed, args), []);
|
||||
|
||||
return { ...accPosts, [user.name]: { ...user, posts } };
|
||||
}, {});
|
||||
|
||||
module.exports = curatePosts;
|
||||
|
||||
Reference in New Issue
Block a user