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:
2024-09-11 05:16:56 +02:00
parent 5eb2eb651a
commit 952392e0d9
11 changed files with 199 additions and 157 deletions

View File

@@ -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;
});