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

Hotfix/v2024.11.23 #924

Merged
merged 45 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
91c7b17
Added integration with aiml
waterstark Nov 5, 2024
e3b861c
Update README.md
surapuramakhil Nov 11, 2024
b64eb03
Add GroqAIModel support
innovatorved Nov 12, 2024
69e45b6
Merge pull request #824 from AIHawk-co/release/v11.15.2024
surapuramakhil Nov 12, 2024
b8d7ffa
README.md updated for GROQ API
innovatorved Nov 13, 2024
3a9e5b7
Update llm_manager.py
surapuramakhil Nov 13, 2024
8c10dcd
Resolve conflicts
waterstark Nov 13, 2024
ed337c7
Merge branch 'release/v11.15.2024' into integration-with-aiml
surapuramakhil Nov 13, 2024
6fc96ed
Merge branch 'release/v3.1.0' into integration-with-aiml
surapuramakhil Nov 13, 2024
be54105
Merge pull request #757 from waterstark/integration-with-aiml
surapuramakhil Nov 13, 2024
72027a8
Merge remote-tracking branch 'upstream/release/v3.1.0'
innovatorved Nov 14, 2024
6280296
groq added in constants
innovatorved Nov 14, 2024
306fca6
just groq version added in requirements
innovatorved Nov 14, 2024
1c1b7f3
Merge pull request #822 from innovatorved/main
surapuramakhil Nov 14, 2024
fd69fc0
perf: :zap: Optimize prompt for better caching
chakaponi Nov 16, 2024
c5955bd
Add AI/ML API info
OctavianTheI Nov 18, 2024
0330af9
Merge pull request #882 from OctavianTheI/patch-1
surapuramakhil Nov 18, 2024
e18e2e6
Merge branch 'release/v4.1.0' into fix/improve-prompts-caching
surapuramakhil Nov 18, 2024
e038183
Merge pull request #872 from chakaponi/fix/improve-prompts-caching
surapuramakhil Nov 18, 2024
1f68c27
"Log time in Job application result"
NamamiShanker Nov 21, 2024
a349a4a
"Refactor logging current time"
NamamiShanker Nov 21, 2024
48481b5
Add files via upload
Tgenz1213 Nov 21, 2024
f21530d
Update pull_request_template.md
Tgenz1213 Nov 21, 2024
eb3e74a
Merge pull request #910 from Tgenz1213/PR_Template
surapuramakhil Nov 22, 2024
218af31
Merge branch 'release/v4.1.0' into feature/log_time
surapuramakhil Nov 22, 2024
3772d6b
Merge pull request #907 from NamamiShanker/feature/log_time
surapuramakhil Nov 22, 2024
51fe7eb
Merge pull request #913 from AIHawk-FOSS/main
surapuramakhil Nov 22, 2024
86ef242
fix: :bug: Change selectors due to new html structure
chakaponi Nov 23, 2024
101a42e
Merge branch 'hotfix/v2024.11.23' into bug/incorrect-element-selectors
surapuramakhil Nov 23, 2024
a2bfb04
test: :white_check_mark: Fix test after removing other developer's hack
chakaponi Nov 23, 2024
d7aeabf
Merge branch 'bug/incorrect-element-selectors' of https://github.com/…
chakaponi Nov 23, 2024
e18fcd3
fixes [BUG]: Not applying to jobs #919
surapuramakhil Nov 24, 2024
ad8635d
Merge pull request #923 from surapuramakhil/hf_brekaing_linkedIn_changes
surapuramakhil Nov 24, 2024
2dd187a
fix: Add classes for temporary solution
chakaponi Nov 24, 2024
ba3a087
test case fixes
surapuramakhil Nov 24, 2024
0e8b6f1
Merge branch 'hotfix/v2024.11.23' into hf_brekaing_linkedIn_changes
surapuramakhil Nov 24, 2024
b624ffd
Merge pull request #925 from surapuramakhil/hf_brekaing_linkedIn_changes
surapuramakhil Nov 24, 2024
76b06ae
Merge branch 'bug/incorrect-element-selectors' into hotfix/v2024.11.23
chakaponi Nov 24, 2024
dba7b10
Rewrite test, merge solution with changes, deduplicate code
chakaponi Nov 24, 2024
170c413
Merge branch 'hotfix/v2024.11.23' into bug/incorrect-element-selectors
chakaponi Nov 24, 2024
8411cf8
style: :art: Fix naming back
chakaponi Nov 25, 2024
22f2c3b
reveiw changes
surapuramakhil Nov 25, 2024
65f8ac9
Merge pull request #905 from chakaponi/bug/incorrect-element-selectors
surapuramakhil Nov 25, 2024
d5295fb
review change
surapuramakhil Nov 25, 2024
b273823
Merge branch 'main' into hotfix/v2024.11.23
surapuramakhil Nov 25, 2024
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
43 changes: 25 additions & 18 deletions src/ai_hawk/job_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import time
from itertools import product
from pathlib import Path
import traceback
from turtle import color

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

from ai_hawk.linkedIn_easy_applier import AIHawkEasyApplier
from config import JOB_MAX_APPLICATIONS, JOB_MIN_APPLICATIONS, MINIMUM_WAIT_TIME_IN_SECONDS
import job
surapuramakhil marked this conversation as resolved.
Show resolved Hide resolved
from src.job import Job
from src.logging import logger

Expand Down Expand Up @@ -155,7 +157,7 @@ def start_applying(self):
logger.debug("Starting the application process for this page...")

try:
jobs = self.get_jobs_from_page()
jobs = self.get_jobs_from_page(scroll=True)
if not jobs:
logger.debug("No more jobs found on this page. Exiting loop.")
break
Expand All @@ -166,7 +168,7 @@ def start_applying(self):
try:
self.apply_jobs()
except Exception as e:
logger.error(f"Error during job application: {e}")
logger.error(f"Error during job application: {e} {traceback.format_exc()}")
continue

logger.debug("Applying to jobs on this page has been completed!")
Expand Down Expand Up @@ -239,7 +241,7 @@ def start_applying(self):
time.sleep(sleep_time)
page_sleep += 1

def get_jobs_from_page(self):
def get_jobs_from_page(self, scroll=False):
surapuramakhil marked this conversation as resolved.
Show resolved Hide resolved

try:

Expand All @@ -252,24 +254,30 @@ def get_jobs_from_page(self):
pass

try:
job_results = self.driver.find_element(By.CLASS_NAME, "jobs-search-results-list")
browser_utils.scroll_slow(self.driver, job_results)
browser_utils.scroll_slow(self.driver, job_results, step=300, reverse=True)
# XPath query to find the ul tag with class scaffold-layout__list-container
job_results_xpath_query = "//ul[contains(@class, 'scaffold-layout__list-container')]"
job_results = self.driver.find_element(By.XPATH, job_results_xpath_query)

job_list_elements = self.driver.find_elements(By.CLASS_NAME, 'scaffold-layout__list-container')[
0].find_elements(By.CLASS_NAME, 'jobs-search-results__list-item')
if scroll:
job_results_scrolableElament = job_results.find_element(By.XPATH,"..")
logger.warning(f'is scrollable: {browser_utils.is_scrollable(job_results_scrolableElament)}')

browser_utils.scroll_slow(self.driver, job_results_scrolableElament)
browser_utils.scroll_slow(self.driver, job_results_scrolableElament, step=300, reverse=True)

job_list_elements = job_results.find_elements(By.XPATH, ".//li[contains(@class, 'jobs-search-results__list-item') and contains(@class, 'ember-view')]")
if not job_list_elements:
logger.debug("No job class elements found on page, skipping.")
return []

return job_list_elements

except NoSuchElementException:
logger.debug("No job results found on the page.")
except NoSuchElementException as e:
logger.warning(f'No job results found on the page. \n expection: {traceback.format_exc()}')
return []

except Exception as e:
logger.error(f"Error while fetching job elements: {e}")
logger.error(f"Error while fetching job elements: {e} {traceback.format_exc()}")
return []

def read_jobs(self):
Expand Down Expand Up @@ -307,8 +315,7 @@ def apply_jobs(self):
except NoSuchElementException:
pass

job_list_elements = self.driver.find_elements(By.CLASS_NAME, 'scaffold-layout__list-container')[
0].find_elements(By.CLASS_NAME, 'jobs-search-results__list-item')
job_list_elements = self.get_jobs_from_page()

if not job_list_elements:
logger.debug("No job class elements found on page, skipping")
Expand Down Expand Up @@ -489,10 +496,10 @@ def job_tile_to_job(self, job_tile) -> Job:
logger.warning("Job link is missing.")

try:
job.company = job_tile.find_element(By.CLASS_NAME, 'job-card-container__primary-description').text
job.company = job_tile.find_element(By.XPATH, ".//div[contains(@class, 'artdeco-entity-lockup__subtitle')]//span").text
logger.debug(f"Job company extracted: {job.company}")
except NoSuchElementException:
logger.warning("Job company is missing.")
except NoSuchElementException as e:
logger.warning(f'Job company is missing. {e} {traceback.format_exc()}')

# Extract job ID from job url
try:
Expand All @@ -512,9 +519,9 @@ def job_tile_to_job(self, job_tile) -> Job:

try:
job.apply_method = job_tile.find_element(By.CLASS_NAME, 'job-card-container__apply-method').text
except NoSuchElementException:
except NoSuchElementException as e:
job.apply_method = "Applied"
logger.warning("Apply method not found, assuming 'Applied'.")
logger.warning(f'Apply method not found, assuming \'Applied\'. {e} {traceback.format_exc()}')

return job

Expand Down
6 changes: 3 additions & 3 deletions tests/test_aihawk_job_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ def test_apply_jobs_with_jobs(mocker, job_manager):
# Simulating two job items
job_elements_list = [job_element_mock, job_element_mock]

# Return the container mock, which itself returns the job elements list
container_mock.find_elements.return_value = job_elements_list
mocker.patch.object(job_manager.driver, 'find_elements',
return_value=[container_mock])

mocker.patch.object(job_manager, 'get_jobs_from_page', return_value=job_elements_list)

job = Job(
title="Title",
company="Company",
Expand Down Expand Up @@ -181,7 +181,7 @@ def test_apply_jobs_with_jobs(mocker, job_manager):
job_manager.apply_jobs()

# Assertions
assert job_manager.driver.find_elements.call_count == 1
assert job_manager.get_jobs_from_page.call_count == 1
# Called for each job element
assert job_manager.job_tile_to_job.call_count == 2
# Called for each job element
Expand Down
Loading