Skip to content

Commit

Permalink
add limit param, reduce to 50
Browse files Browse the repository at this point in the history
  • Loading branch information
mattdiamond committed Jan 12, 2025
1 parent 7feabd7 commit dc7b28b
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions ouija.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const
SUBREDDIT_NAME = 'AskOuija',
OUIJA_RESULT_CLASS = 'ouija-result',
COMMENT_SCORE_THRESHOLD = process.env.THRESHOLD ?? 10,
LIMIT = process.env.LIMIT ?? 50,

r = new snoowrap(config),
splitter = new GraphemeSplitter(),
Expand All @@ -32,9 +33,9 @@ const
// -------------- { MAIN } -----------------

if (submissionId){
processPost(r.get_submission(submissionId));
processPost(r.getSubmission(submissionId));
} else {
checkHot();
checkHot(LIMIT);
checkReported();
}

Expand Down Expand Up @@ -259,9 +260,13 @@ class CommentDuplicateHandler {

// -------------- functions ----------------

function checkHot(){
console.log('checking last 100 hot posts');
r.getHot(SUBREDDIT_NAME, { limit: 100 })
function checkHot(limit){
if (limit == null) {
throw new Error('No limit specified');
}

console.log(`checking last ${limit} hot posts`);
r.getHot(SUBREDDIT_NAME, { limit })
.then(posts => {
return Promise.all(
posts.filter(isUnanswered).map(processPost)
Expand Down

0 comments on commit dc7b28b

Please sign in to comment.