Skip to content

Commit

Permalink
fix: only enrich with parsing new jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
the-forest-tree authored and the-forest-tree committed Nov 30, 2023
1 parent afd75ae commit 5b9e6fd
Showing 1 changed file with 25 additions and 17 deletions.
42 changes: 25 additions & 17 deletions src/hrflow_connectors/connectors/hrflow/warehouse/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand All @@ -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
)
Expand Down

0 comments on commit 5b9e6fd

Please sign in to comment.