Skip to content

Commit 8d3ec17

Browse files
feat(jobs,notifications): add job existence short-circuiting and subscription logging; shrink metadata generation
1 parent a20790b commit 8d3ec17

File tree

5 files changed

+43
-874
lines changed

5 files changed

+43
-874
lines changed

src/jobs/job.service.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,17 @@ export class JobService {
155155
return job;
156156
}
157157

158+
/**
159+
* Lightweight existence check by canonical job URL.
160+
* Returns true if a job record already exists. Used by external
161+
* fetch/store services to short-circuit processing once we start
162+
* encountering previously ingested (older) records.
163+
*/
164+
async jobExists(url: string): Promise<boolean> {
165+
const existing = await this.prisma.job.findUnique({ where: { url }, select: { id: true } });
166+
return !!existing;
167+
}
168+
158169
/**
159170
* Create a new job listing
160171
* Creates a job with associated company, tags, and metadata

src/jobs/reddit.service.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ export class RedditService {
7272
data: post,
7373
},
7474
};
75+
// EARLY STOP: if this job already exists we assume all subsequent
76+
// posts are older (API returns newest first) and can stop processing.
77+
const exists = await this.jobService.jobExists(post.url);
78+
if (exists) {
79+
this.logger.log(`Encountered existing Reddit job ${post.url}; stopping further processing.`);
80+
break;
81+
}
7582
const upsertedJob = await this.jobService.upsertJob(jobInput);
7683
// Send notifications for new jobs
7784
const notificationPayload: NotificationPayload = {

src/jobs/web3career.service.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ export class Web3CareerService {
5252
data: job,
5353
},
5454
};
55+
// EARLY STOP: if job already exists assume remaining are older.
56+
const exists = await this.jobService.jobExists(job.apply_url);
57+
if (exists) {
58+
this.logger.log(`Encountered existing Web3Career job ${job.apply_url}; stopping further processing.`);
59+
break;
60+
}
5561
const upserted = await this.jobService.upsertJob(jobInput);
5662
newJobs.push(upserted);
5763
} catch (error: any) {

0 commit comments

Comments
 (0)