From 61901e1db182668496b223eafb437c92cc6d6bf9 Mon Sep 17 00:00:00 2001 From: Konstantin Rybakov Date: Mon, 5 Aug 2024 10:29:47 +0300 Subject: [PATCH] only insert if there are jobs --- lib/hiring-platforms/ashby.ts | 6 ++++-- lib/hiring-platforms/greenhouse.ts | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/hiring-platforms/ashby.ts b/lib/hiring-platforms/ashby.ts index a2a5708..8ce355b 100644 --- a/lib/hiring-platforms/ashby.ts +++ b/lib/hiring-platforms/ashby.ts @@ -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 { diff --git a/lib/hiring-platforms/greenhouse.ts b/lib/hiring-platforms/greenhouse.ts index eb0e34c..f8658a8 100644 --- a/lib/hiring-platforms/greenhouse.ts +++ b/lib/hiring-platforms/greenhouse.ts @@ -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(