Skip to content

Commit

Permalink
Merge pull request #884 from 49Simon/fix-saving-failed-applications
Browse files Browse the repository at this point in the history
fix: prevent failed applications from being saved in success.json

Co-authored-by: 49Simon <85809106+49Simon@users.noreply.github.com>
  • Loading branch information
surapuramakhil and feder-cr authored Dec 2, 2024
2 parents 1c1b2b2 + 6ad0119 commit cc0b814
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/ai_hawk/job_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import time
from itertools import product
from pathlib import Path
from turtle import color
from datetime import datetime

from inputimeout import inputimeout, TimeoutOccurred
Expand All @@ -14,6 +13,7 @@

from ai_hawk.linkedIn_easy_applier import AIHawkEasyApplier
from config import JOB_MAX_APPLICATIONS, JOB_MIN_APPLICATIONS, MINIMUM_WAIT_TIME_IN_SECONDS
from src.custom_exception import JobNotSuitableException
from src.job import Job
from src.logging import logger

Expand Down Expand Up @@ -412,6 +412,10 @@ def apply_jobs(self):
self.easy_applier_component.job_apply(job)
self.write_to_file(job, "success")
logger.debug(f"Applied to job: {job.title} at {job.company}")
except JobNotSuitableException as e:
logger.debug(f"Job not suitable for application: {job.title} at {job.company}")
self.write_to_file(job, "skipped", str(e))
continue
except Exception as e:
logger.error(f"Failed to apply for {job.title} at {job.company}: {e}",exc_info=True)
self.write_to_file(job, "failed", f"Application error: {str(e)}")
Expand Down
3 changes: 2 additions & 1 deletion src/ai_hawk/linkedIn_easy_applier.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from jobContext import JobContext
from job_application import JobApplication
from job_application_saver import ApplicationSaver
from src.custom_exception import JobNotSuitableException
import src.utils as utils
from src.logging import logger
from src.job import Job
Expand Down Expand Up @@ -157,7 +158,7 @@ def job_apply(self, job: Job):

# Todo: add this job to skip list with it's reason
if not self.gpt_answerer.is_job_suitable():
return
raise JobNotSuitableException("LLM score determined this job is not suitable for you")

logger.debug("Attempting to click 'Easy Apply' button")
actions = ActionChains(self.driver)
Expand Down
4 changes: 4 additions & 0 deletions src/custom_exception.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class JobNotSuitableException(Exception):
def __init__(self, message):
self.message = message
super().__init__(self.message)

0 comments on commit cc0b814

Please sign in to comment.