Using YAML rather than TSV for index files. Improves both readability and reindexability.

This commit is contained in:
2018-06-30 03:33:30 +02:00
parent 1c4ec06f68
commit 74e36a6826
9 changed files with 73 additions and 91 deletions

View File

@@ -6,7 +6,7 @@ const omit = require('object.omit');
const dissectLink = require('../dissectLink.js');
const hashPost = require('./hashPost.js');
function curatePost(acc, post, user, index, indexedPostIds, processed, args) {
function curatePost(acc, post, user, index, processed, args) {
const host = dissectLink(post.url);
const permalink = `https://reddit.com${post.permalink}`;
@@ -25,7 +25,7 @@ function curatePost(acc, post, user, index, indexedPostIds, processed, args) {
hash: hashPost(post),
};
if (indexedPostIds.includes(post.id)) {
if (user.indexed.find(entry => entry.id === post.id)) {
return { ...acc, indexed: { ...acc.indexed, [post.id]: curatedPost } };
}
@@ -72,10 +72,9 @@ function curatePost(acc, post, user, index, indexedPostIds, processed, args) {
const curatePosts = (userPosts, args) => Object.values(userPosts).reduce((accPosts, user) => {
const processed = new Set();
const indexedPostIds = user.indexed.map(entry => entry.postId);
const { posts, indexed } = user.posts.reduce((accUserPosts, post, index) =>
curatePost(accUserPosts, post, user, index, indexedPostIds, processed, args), { posts: [], indexed: {} });
curatePost(accUserPosts, post, user, index, processed, args), { posts: [], indexed: {} });
const indexedLength = Object.keys(indexed).length;