From 5b9e6fd678bea9f82a0550b6f2a26902553a5bdd Mon Sep 17 00:00:00 2001 From: the-forest-tree Date: Thu, 30 Nov 2023 09:48:28 +0000 Subject: [PATCH] fix: only enrich with parsing new jobs --- .../connectors/hrflow/warehouse/job.py | 42 +++++++++++-------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/src/hrflow_connectors/connectors/hrflow/warehouse/job.py b/src/hrflow_connectors/connectors/hrflow/warehouse/job.py index bb3625906..8e1ab71b9 100644 --- a/src/hrflow_connectors/connectors/hrflow/warehouse/job.py +++ b/src/hrflow_connectors/connectors/hrflow/warehouse/job.py @@ -183,25 +183,20 @@ def write( raise Exception("Failed to archive job") adapter.info("Archiving finished") - jobs_to_write = [] - if parameters.enrich_with_parsing: - adapter.info("Enrich with parsing enabled. Starting parsing") - for job in jobs: - try: - enrich_job_with_parsing(hrflow_client, job) - jobs_to_write.append(job) - except JobParsingException as e: - adapter.error( - "Failed to parse job response={}".format(e.client_response) - ) - failed_jobs.append(job) - adapter.info("Parsing finished") - else: - jobs_to_write = jobs - - for job in jobs_to_write: + for job in jobs: reference = job.get("reference") if reference is None: + if parameters.enrich_with_parsing: + adapter.info("Starting parsing for job without reference") + try: + enrich_job_with_parsing(hrflow_client, job) + adapter.info("Parsing finished") + except JobParsingException as e: + adapter.error( + "Failed to parse job response={}".format(e.client_response) + ) + failed_jobs.append(job) + continue response = hrflow_client.job.indexing.add_json( board_key=parameters.board_key, job_json=job ) @@ -217,6 +212,19 @@ def write( board_key=parameters.board_key, reference=reference ) if "Unable to find object: job" in response["message"]: + if parameters.enrich_with_parsing: + adapter.info( + "Starting parsing for job with reference={}".format(reference) + ) + try: + enrich_job_with_parsing(hrflow_client, job) + adapter.info("Parsing finished") + except JobParsingException as e: + adapter.error( + "Failed to parse job response={}".format(e.client_response) + ) + failed_jobs.append(job) + continue response = hrflow_client.job.indexing.add_json( board_key=parameters.board_key, job_json=job )