From 60973a0e7049bce534e7318bd87034440053ed4d Mon Sep 17 00:00:00 2001 From: DebaucheryLibrarian Date: Wed, 11 Sep 2024 05:16:57 +0200 Subject: [PATCH] Added post score to index and variables. --- src/curate/posts.js | 1 + src/interpolate.js | 1 + src/save/writeToIndex.js | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/curate/posts.js b/src/curate/posts.js index 9929208..48585b6 100644 --- a/src/curate/posts.js +++ b/src/curate/posts.js @@ -61,6 +61,7 @@ function curatePost(acc, post, user, index, indexed, ignoreIds, processed, args) url: post.url, datetime: new Date(post.created_utc * 1000), subreddit: post.subreddit.display_name, + score: post.score, preview: post.preview ? post.preview.images.map(image => image.source) : null, host, hash: hashPost(post), diff --git a/src/interpolate.js b/src/interpolate.js index 6eb7aeb..27e1873 100644 --- a/src/interpolate.js +++ b/src/interpolate.js @@ -41,6 +41,7 @@ function interpolate(pattern, user, post, item, strip = true, dateFormat = confi $postIndex: post.index + config.library.indexOffset, $postHash: post.hash, $url: post.url, + $score: post.score, $subreddit: post.subreddit, $hostLabel: post.host.label, $hostId: post.host.id, diff --git a/src/save/writeToIndex.js b/src/save/writeToIndex.js index 734103e..1aff509 100644 --- a/src/save/writeToIndex.js +++ b/src/save/writeToIndex.js @@ -20,6 +20,7 @@ async function writeToIndex(posts, profilePaths, user, args) { hostId: post.host.id, date: post.datetime, indexed: now, + score: post.score, title: post.title, }; @@ -39,7 +40,7 @@ async function writeToIndex(posts, profilePaths, user, args) { }; if (!data.profile.image && !data.profile.description && !data.posts.length) { - return; + return false; } return save(filepath, textToStream(yaml.safeDump(data)));