Skip to content

Commit

Permalink
Merge pull request #28 from acmcsufoss/blacklist-01
Browse files Browse the repository at this point in the history
Create Blocklist class
  • Loading branch information
boushrabettir authored Sep 21, 2023
2 parents 932765b + 1adfacb commit 9750f50
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 32 deletions.
11 changes: 11 additions & 0 deletions blocklist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class Blockist:
"""A class holding methods to determine if a company is blocklisted"""

BLOCKLISTED_COMPANIES = set(
["Pattern Learning AI - Career & Tech Recruitment Reimagined!"]
)

def is_blacklisted_company(self, company: str) -> bool:
"""Determines if the company is blacklisted or not"""

return True if company in self.BLOCKLISTED_COMPANIES else False
30 changes: 16 additions & 14 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
import opportunity as opps
from opportunity import Opportunity, OpportunityType
from dotenv import load_dotenv
from blacklist import BlackList

load_dotenv() # To obtain keys from the .env file


# ----------------- POSTGRES -----------------

TABLE_NAME = os.getenv("DB_TABLE")
MAX_LIST_LENGTH = 13
MAX_LIST_LENGTH = 15


def create():
Expand Down Expand Up @@ -49,19 +50,20 @@ def request_github_internship24_data() -> List[Opportunity]:
elements = cell.find_all("td")

company = elements[0].text
title = elements[1].text
location = elements[2].text
link = elements[3]
if "🔒" not in link.text:
opportunity = Opportunity(
company,
title,
location,
link.find("a")["href"],
0,
OpportunityType.INTERNSHIP.value,
)
github_list.append(opportunity)
if not BlackList().is_blacklisted_company(company):
title = elements[1].text
location = elements[2].text
link = elements[3]
if "🔒" not in link.text:
opportunity = Opportunity(
company,
title,
location,
link.find("a")["href"],
0,
OpportunityType.INTERNSHIP.value,
)
github_list.append(opportunity)

return github_list

Expand Down
39 changes: 21 additions & 18 deletions utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
import json
import google.generativeai as palm
from bs4 import BeautifulSoup
from opportunity import Opportunity, OpportunityType
from opportunity import Opportunity
from blacklist import BlackList

# ----------------- FOR CLI LIBRARY COMMAND -----------------

Expand Down Expand Up @@ -74,23 +75,25 @@ def blueprint_opportunity_formatter(
internship_list = []
for elem in div:
company = elem.find(class_=company_elem).text.strip()
title = elem.find(class_=title_elem).text.strip()
location = elem.find(class_=location_elem).text.strip()
link = elem.find(class_=link_elem)["href"].split("?")[0]
processed = 0

date_difference = calculate_day_difference(elem)
if len(internship_list) < len_of_jobs:
if date_limit and int(days_needed_command_value) >= date_difference:
opportunity = Opportunity(
company, title, location, link, processed, opp_type
)
else:
opportunity = Opportunity(
company, title, location, link, processed, opp_type
)

internship_list.append(opportunity)
if not BlackList().is_blacklisted_company(company):
title = elem.find(class_=title_elem).text.strip()
location = elem.find(class_=location_elem).text.strip()
link = elem.find(class_=link_elem)["href"].split("?")[0]
processed = 0

date_difference = calculate_day_difference(elem)

if len(internship_list) < len_of_jobs:
if date_limit and int(days_needed_command_value) >= date_difference:
opportunity = Opportunity(
company, title, location, link, processed, opp_type
)
else:
opportunity = Opportunity(
company, title, location, link, processed, opp_type
)

internship_list.append(opportunity)

return internship_list

Expand Down

0 comments on commit 9750f50

Please sign in to comment.