Skip to content

Commit 9ed4cb2

Browse files
Only include reddit posts with [HIRING].
1 parent aa3efbb commit 9ed4cb2

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

src/jobs/reddit.service.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,21 @@ export class RedditService {
2525
const response = await axios.default.get(`https://www.reddit.com/r/${subreddit}/new.json?limit=10`, {
2626
timeout: 5000,
2727
});
28-
const subredditPosts = response.data.data.children.map((child: any) => ({
29-
title: child.data.title,
30-
author: child.data.author,
31-
subreddit: child.data.subreddit,
32-
url: child.data.url,
33-
postedAt: new Date(child.data.created_utc * 1000),
34-
body: child.data.selftext,
35-
bodyHtml: child.data.selftext_html,
36-
upvotes: child.data.ups,
37-
downvotes: child.data.downs,
38-
}));
39-
this.logger.info(`Found ${subredditPosts.length} post(s) in /r/${subreddit}`);
28+
// Only include posts with [HIRING] in the title (case-insensitive)
29+
const subredditPosts = response.data.data.children
30+
.map((child: any) => ({
31+
title: child.data.title,
32+
author: child.data.author,
33+
subreddit: child.data.subreddit,
34+
url: child.data.url,
35+
postedAt: new Date(child.data.created_utc * 1000),
36+
body: child.data.selftext,
37+
bodyHtml: child.data.selftext_html,
38+
upvotes: child.data.ups,
39+
downvotes: child.data.downs,
40+
}))
41+
.filter((post: any) => /\[hiring\]/i.test(post.title));
42+
this.logger.info(`Found ${subredditPosts.length} [HIRING] post(s) in /r/${subreddit}`);
4043
allPosts.push(...subredditPosts);
4144
} catch (error: any) {
4245
this.logger.error(`Error fetching /r/${subreddit}:`, error.message);

0 commit comments

Comments
 (0)