Skip to content

Commit

Permalink
only insert if there are jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
konstrybakov committed Aug 5, 2024
1 parent 24d8645 commit 61901e1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lib/hiring-platforms/ashby.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@ export class Ashby extends HiringPlatform {

const openJobs = result.jobs.map(job => this.mapJob(job, companyId))

await queryInsertJobs(openJobs)
await queryMarkJobsAsClosed(companyId, openJobs)
if (openJobs.length) {
await queryInsertJobs(openJobs)
await queryMarkJobsAsClosed(companyId, openJobs)
}
}

private mapJob(job: AshbyJob, companyId: SelectCompany['id']): InsertJob {
Expand Down
6 changes: 4 additions & 2 deletions lib/hiring-platforms/greenhouse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ export class Greenhouse extends HiringPlatform {

const openJobs = result.jobs.map(job => this.mapJob(job, companyId))

await queryInsertJobs(openJobs)
await queryMarkJobsAsClosed(companyId, openJobs)
if (openJobs.length) {
await queryInsertJobs(openJobs)
await queryMarkJobsAsClosed(companyId, openJobs)
}
}

private mapJob(
Expand Down

0 comments on commit 61901e1

Please sign in to comment.