Spaces:
Running
Running
Commit
·
b3e55ce
1
Parent(s):
fe40eee
Make the JobDescription serializable
Browse files- JobDescription.py +50 -0
JobDescription.py
CHANGED
@@ -13,6 +13,40 @@ class JobDescription:
|
|
13 |
self.ai_result : AIInformation = None
|
14 |
self.salary_range = ""
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
def format_should_apply(self, should_apply : bool):
|
17 |
if should_apply:
|
18 |
return "⭐ "
|
@@ -82,3 +116,19 @@ class AIInformation:
|
|
82 |
self.is_an_internship = obj["is_an_internship"]
|
83 |
self.salary_range = obj["salary_range"]
|
84 |
self.should_apply : bool = obj["should_apply"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
self.ai_result : AIInformation = None
|
14 |
self.salary_range = ""
|
15 |
|
16 |
+
def to_dict(self):
|
17 |
+
return {
|
18 |
+
"title": self.title,
|
19 |
+
"company": self.company,
|
20 |
+
"url": self.url,
|
21 |
+
"company_url": self.company_url,
|
22 |
+
"published_at": self.published_at,
|
23 |
+
"job_description": self.job_description,
|
24 |
+
"organization_logo_url": self.organization_logo_url,
|
25 |
+
"ai_result": self.ai_result.to_dict() if self.ai_result else None,
|
26 |
+
"salary_range": self.salary_range
|
27 |
+
}
|
28 |
+
|
29 |
+
@staticmethod
|
30 |
+
def from_dict(data):
|
31 |
+
ai_result = AIInformation.from_dict(data["ai_result"]) if data["ai_result"] else None
|
32 |
+
return JobDescription(
|
33 |
+
title=data["title"],
|
34 |
+
company=data["company"],
|
35 |
+
url=data["url"],
|
36 |
+
company_url=data["company_url"],
|
37 |
+
job_description=data["job_description"]
|
38 |
+
)._replace(
|
39 |
+
published_at=data["published_at"],
|
40 |
+
organization_logo_url=data["organization_logo_url"],
|
41 |
+
ai_result=ai_result,
|
42 |
+
salary_range=data["salary_range"]
|
43 |
+
)
|
44 |
+
|
45 |
+
def _replace(self, **kwargs):
|
46 |
+
for key, value in kwargs.items():
|
47 |
+
setattr(self, key, value)
|
48 |
+
return self
|
49 |
+
|
50 |
def format_should_apply(self, should_apply : bool):
|
51 |
if should_apply:
|
52 |
return "⭐ "
|
|
|
116 |
self.is_an_internship = obj["is_an_internship"]
|
117 |
self.salary_range = obj["salary_range"]
|
118 |
self.should_apply : bool = obj["should_apply"]
|
119 |
+
|
120 |
+
def to_dict(self):
|
121 |
+
return {
|
122 |
+
"company_description": self.company_description,
|
123 |
+
"position_summary": self.position_summary,
|
124 |
+
"language_requirements": self.language_requirements,
|
125 |
+
"experience_requirements": self.experience_requirements,
|
126 |
+
"is_an_internship": self.is_an_internship,
|
127 |
+
"salary_range": self.salary_range,
|
128 |
+
"should_apply": self.should_apply
|
129 |
+
}
|
130 |
+
|
131 |
+
@staticmethod
|
132 |
+
def from_dict(data):
|
133 |
+
json_dump = json.dumps(data)
|
134 |
+
return AIInformation(json_dump)
|