Skip to content

Commit

Permalink
Merge pull request #595 from BlackHoleExelion/v1
Browse files Browse the repository at this point in the history
  • Loading branch information
feder-cr authored Oct 24, 2024
2 parents 0ce6336 + ec3901c commit b250b06
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
3 changes: 3 additions & 0 deletions data_folder/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ title_blacklist:
- word1
- word2

location_blacklist:
- Brazil

job_applicants_threshold:
min_applicants: 0
max_applicants: 30
Expand Down
3 changes: 3 additions & 0 deletions data_folder_example/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ title_blacklist:
- word1
- word2

location_blacklist:
- Brazil

job_applicants_threshold:
min_applicants: 0
max_applicants: 30
Expand Down
11 changes: 6 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,22 @@ def validate_config(config_yaml_path: Path) -> dict:
'date': dict,
'positions': list,
'locations': list,
'location_blacklist': list,
'distance': int,
'companyBlacklist': list,
'titleBlacklist': list,
'company_blacklist': list,
'title_blacklist': list,
'llm_model_type': str,
'llm_model': str
}

for key, expected_type in required_keys.items():
if key not in parameters:
if key in ['companyBlacklist', 'titleBlacklist']:
if key in ['company_blacklist', 'title_blacklist', 'location_blacklist']:
parameters[key] = []
else:
raise ConfigError(f"Missing or invalid key '{key}' in config file {config_yaml_path}")
elif not isinstance(parameters[key], expected_type):
if key in ['companyBlacklist', 'titleBlacklist'] and parameters[key] is None:
if key in ['company_blacklist', 'title_blacklist', 'location_blacklist'] and parameters[key] is None:
parameters[key] = []
else:
raise ConfigError(f"Invalid type for key '{key}' in config file {config_yaml_path}. Expected {expected_type}.")
Expand Down Expand Up @@ -97,7 +98,7 @@ def validate_config(config_yaml_path: Path) -> dict:
raise ConfigError(f"Invalid distance value in config file {config_yaml_path}. Must be one of: {approved_distances}")

# Ensure blacklists are lists
for blacklist in ['companyBlacklist', 'titleBlacklist']:
for blacklist in ['company_blacklist', 'title_blacklist','location_blacklist']:
if not isinstance(parameters.get(blacklist), list):
raise ConfigError(f"'{blacklist}' must be a list in config file {config_yaml_path}")
if parameters[blacklist] is None:
Expand Down
18 changes: 10 additions & 8 deletions src/aihawk_job_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def set_parameters(self, parameters):
logger.debug("Setting parameters for AIHawkJobManager")
self.company_blacklist = parameters.get('company_blacklist', []) or []
self.title_blacklist = parameters.get('title_blacklist', []) or []
self.location_blacklist = parameters.get('location_blacklist', []) or []
self.positions = parameters.get('positions', [])
self.locations = parameters.get('locations', [])
self.apply_once_at_company = parameters.get('apply_once_at_company', False)
Expand Down Expand Up @@ -276,8 +277,8 @@ def read_jobs(self):
raise Exception("No job class elements found on page")
job_list = [Job(*self.extract_job_information_from_tile(job_element)) for job_element in job_list_elements]
for job in job_list:
if self.is_blacklisted(job.title, job.company, job.link):
utils.printyellow(f"Blacklisted {job.title} at {job.company}, skipping...")
if self.is_blacklisted(job.title, job.company, job.link, job.location):
utils.printyellow(f"Blacklisted {job.title} at {job.company} in {job.location}, skipping...")
self.write_to_file(job, "skipped")
continue
try:
Expand Down Expand Up @@ -361,8 +362,8 @@ def apply_jobs(self):
"""


if self.is_blacklisted(job.title, job.company, job.link):
logger.debug(f"Job blacklisted: {job.title} at {job.company}")
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")
continue
if self.is_already_applied_to_job(job.title, job.company, job.link):
Expand Down Expand Up @@ -467,16 +468,17 @@ def extract_job_information_from_tile(self, job_tile):

return job_title, company, job_location, link, apply_method

def is_blacklisted(self, job_title, company, link):
logger.debug(f"Checking if job is blacklisted: {job_title} at {company}")
def is_blacklisted(self, job_title, company, link, job_location):
logger.debug(f"Checking if job is blacklisted: {job_title} at {company} in {job_location}")
job_title_words = job_title.lower().split(' ')
title_blacklisted = any(word in job_title_words for word in map(str.lower, self.title_blacklist))
company_blacklisted = company.strip().lower() in (word.strip().lower() for word in self.company_blacklist)
location_blacklisted= job_location.strip().lower() in (word.strip().lower() for word in self.location_blacklist)
link_seen = link in self.seen_jobs
is_blacklisted = title_blacklisted or company_blacklisted or link_seen
is_blacklisted = title_blacklisted or company_blacklisted or location_blacklisted or link_seen
logger.debug(f"Job blacklisted status: {is_blacklisted}")

return title_blacklisted or company_blacklisted or link_seen
return title_blacklisted or company_blacklisted or location_blacklisted or link_seen

def is_already_applied_to_job(self, job_title, company, link):
link_seen = link in self.seen_jobs
Expand Down

0 comments on commit b250b06

Please sign in to comment.