refactor
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
Das Programm lädt Stellenangebote der Bundesagentur für Arbeit für
|
||||
ausgewählte Entwickler-Suchbegriffe.
|
||||
Mit **JEV** werden die Anzeigen danach darauf geprüft,
|
||||
Mit **JEV.ai** werden die Anzeigen danach darauf geprüft,
|
||||
ob sie zu meinem TechStack passen.
|
||||
Geeignete Stellenangebote werden anschließend gemeinsam in `stellenangebote.html`
|
||||
ausgegeben.
|
||||
@@ -13,32 +13,14 @@ defapi_token = os.getenv("DEF_API_TOKEN")
|
||||
arbeitsagentur_base_url = "https://rest.arbeitsagentur.de/"
|
||||
defapi_url = "https://api.defapi.org/api/v1/decisions"
|
||||
timeout = 60
|
||||
|
||||
|
||||
jev_instructions_file = "jev-instructions.json"
|
||||
search_strings = ["Developer", "Webentwickler", "Softwareentwickler"]
|
||||
wo = "Pforzheim"
|
||||
combined_response: JobSearchResponse = {"ergebnisliste": []}
|
||||
|
||||
def main():
|
||||
load_dotenv()
|
||||
jobs_data = []
|
||||
for search in search_strings:
|
||||
jobs_data = get_jobs(search)
|
||||
combined_response["ergebnisliste"].extend(jobs_data["ergebnisliste"])
|
||||
|
||||
job_refs = get_job_refs(combined_response)
|
||||
jev_instructions = read_json()
|
||||
print(jobs_data)
|
||||
html_parts = []
|
||||
for job_ref in job_refs:
|
||||
data = classify(job_ref, jev_instructions)
|
||||
if data:
|
||||
html_parts.append(html_helper.render_html(data))
|
||||
|
||||
html_helper.write_html(html_parts)
|
||||
|
||||
|
||||
def read_json() -> dict:
|
||||
with open("jev-instructions.json", mode="r", encoding="utf-8") as read_file:
|
||||
def read_json(file_name) -> dict:
|
||||
with open(file_name, mode="r", encoding="utf-8") as read_file:
|
||||
jev_instructions = json.load(read_file)
|
||||
read_file.close()
|
||||
return jev_instructions
|
||||
@@ -61,7 +43,7 @@ def get_jobs(search_string: str) -> JobSearchResponse:
|
||||
params = {
|
||||
"angebotsart": "1",
|
||||
"was": search_string,
|
||||
"wo": "Pforzheim",
|
||||
"wo": wo,
|
||||
"umkreis": "50",
|
||||
"arbeitszeit": "ho;vz;tz",
|
||||
"page": "1",
|
||||
@@ -99,7 +81,7 @@ def classify(job_ref: str, jev_instructions: dict) -> tuple[Stellenangebot, floa
|
||||
"model": "typesafe/jev-1.13",
|
||||
"state": job_data["stellenangebotsBeschreibung"],
|
||||
"questions": {
|
||||
"job_validation": jev_instructions
|
||||
"job_classification": jev_instructions
|
||||
}}
|
||||
|
||||
response = requests.post(defapi_url, headers=headers, json=data, timeout=timeout)
|
||||
@@ -107,7 +89,7 @@ def classify(job_ref: str, jev_instructions: dict) -> tuple[Stellenangebot, floa
|
||||
if response.status_code == 200:
|
||||
response_data = response.json()
|
||||
answers = response_data["answers"]
|
||||
score = answers["job_validation"]["noul"]
|
||||
score = answers["job_classification"]["noul"]
|
||||
if score > 0.6:
|
||||
return job_data, score
|
||||
else:
|
||||
@@ -117,6 +99,19 @@ def classify(job_ref: str, jev_instructions: dict) -> tuple[Stellenangebot, floa
|
||||
return None
|
||||
|
||||
|
||||
def main():
|
||||
for search in search_strings:
|
||||
jobs_data = get_jobs(search)
|
||||
combined_response["ergebnisliste"].extend(jobs_data["ergebnisliste"])
|
||||
|
||||
jev_instructions = read_json(jev_instructions_file)
|
||||
html_parts = []
|
||||
for job_ref in get_job_refs(combined_response):
|
||||
data = classify(job_ref, jev_instructions)
|
||||
if data:
|
||||
html_parts.append(html_helper.render_html(data))
|
||||
|
||||
html_helper.write_html(html_parts)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import json
|
||||
|
||||
import markdown
|
||||
from tinyhtml import h, raw, render
|
||||
from stellenangebot import Stellenangebot
|
||||
from modules.stellenangebot import Stellenangebot
|
||||
|
||||
|
||||
def render_html(data: tuple[Stellenangebot, float]) -> str:
|
||||
job_data, score = data
|
||||
|
||||
Reference in New Issue
Block a user