Building user posts object after fetching user to ensure user fetched posts and directly fetched posts are added to the same user key. Refactor to make better use of functions. Moved profile detail saving call to content fetch. No longer attempting and failing to save profile details for deleted users (directory would not exist).
This commit is contained in:
@@ -5,12 +5,12 @@ const config = require('config');
|
||||
const archives = require('./archives.js');
|
||||
|
||||
function getArchivePostIds(username, exclude) {
|
||||
console.log('Searching archives for posts...');
|
||||
console.log(`Finding archived posts for '${username}'...`);
|
||||
|
||||
return Promise.all(config.fetch.archives.reddit.map(source => archives[source](username))).then(postIds => postIds.flatten()).then(postIds => {
|
||||
return exclude ? postIds.filter(postId => !exclude.includes(postId)) : postIds;
|
||||
}).then(postIds => {
|
||||
console.log(`Found ${postIds.length} unique archived posts`);
|
||||
console.log(`Found ${postIds.length} unique archived posts for user '${username}'`);
|
||||
|
||||
return postIds;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user