PaulMartrenchar commited on
Commit
3628d9d
·
1 Parent(s): 41c3c39

fix on datetime serialization

Browse files
Files changed (1) hide show
  1. JobDescription.py +7 -12
JobDescription.py CHANGED
@@ -19,7 +19,7 @@ class JobDescription:
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,
@@ -29,23 +29,18 @@ class JobDescription:
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:
 
19
  "company": self.company,
20
  "url": self.url,
21
  "company_url": self.company_url,
22
+ "published_at": self.published_at.isoformat() if self.published_at else None,
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,
 
29
  @staticmethod
30
  def from_dict(data):
31
  ai_result = AIInformation.from_dict(data["ai_result"]) if data["ai_result"] else None
32
+ job_desc = 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
  )
39
+ job_desc.published_at = datetime.fromisoformat(data["published_at"]) if data["published_at"] else None
40
+ job_desc.organization_logo_url = data["organization_logo_url"]
41
+ job_desc.ai_result = ai_result
42
+ job_desc.salary_range = data["salary_range"]
43
+ return job_desc
44
 
45
  def format_should_apply(self, should_apply : bool):
46
  if should_apply: