From 26606e1f078279cb5175f4aa155947d72e579299 Mon Sep 17 00:00:00 2001 From: cjbbb <53784676+cjbbb@users.noreply.github.com> Date: Tue, 5 Nov 2024 15:54:59 -0500 Subject: [PATCH] Fixed Issue #737, add Skip, Failed reason Fixed Issue #737, add Skip, Failed reason --- src/ai_hawk/job_manager.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/ai_hawk/job_manager.py b/src/ai_hawk/job_manager.py index 6b9f1116..2228fd1a 100644 --- a/src/ai_hawk/job_manager.py +++ b/src/ai_hawk/job_manager.py @@ -376,13 +376,13 @@ def apply_jobs(self): continue if self.is_blacklisted(job.title, job.company, job.link, job.location): logger.debug(f"Job blacklisted: {job.title} at {job.company} in {job.location}") - self.write_to_file(job, "skipped") + self.write_to_file(job, "skipped", "Job blacklisted") continue if self.is_already_applied_to_job(job.title, job.company, job.link): - self.write_to_file(job, "skipped") + self.write_to_file(job, "skipped", "Already applied to this job") continue if self.is_already_applied_to_company(job.company): - self.write_to_file(job, "skipped") + self.write_to_file(job, "skipped", "Already applied to this company") continue try: if job.apply_method not in {"Continue", "Applied", "Apply"}: @@ -391,10 +391,10 @@ def apply_jobs(self): logger.debug(f"Applied to job: {job.title} at {job.company}") except Exception as e: logger.error(f"Failed to apply for {job.title} at {job.company}: {e}") - self.write_to_file(job, "failed") + self.write_to_file(job, "failed", f"Application error: {str(e)}") continue - def write_to_file(self, job, file_name): + def write_to_file(self, job, file_name, reason=None): logger.debug(f"Writing job application result to file: {file_name}") pdf_path = Path(job.pdf_path).resolve() pdf_path = pdf_path.as_uri() @@ -406,6 +406,10 @@ def write_to_file(self, job, file_name): "job_location": job.location, "pdf_path": pdf_path } + + if reason: + data["reason"] = reason + file_path = self.output_file_directory / f"{file_name}.json" if not file_path.exists(): with open(file_path, 'w', encoding='utf-8') as f: