Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: add Skip, Failed reason #765

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/ai_hawk/job_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"}:
Expand All @@ -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()
Expand All @@ -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:
Expand Down
Loading