File size: 1,506 Bytes
b617fcc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from src.scrapers.base import Job


def map_job(j: dict) -> Job:
    loc = j.get("location") or {}
    if isinstance(loc, dict):
        city    = loc.get("city", "") or ""
        state   = loc.get("state", "") or ""
        country = loc.get("country", "") or ""
        location_str = ", ".join(filter(None, [city, state, country])) or "Remote"
    else:
        location_str = str(loc) if loc else "Remote"

    comp = j.get("compensation") or {}
    salary_str = "Not specified"
    if comp.get("minAmount"):
        currency = comp.get("currency", "")
        amount   = comp["minAmount"]
        interval = comp.get("interval", "yearly")
        max_amt  = comp.get("maxAmount")
        if max_amt and max_amt != amount:
            salary_str = f"{currency}{amount:,}{max_amt:,}/{interval}"
        else:
            salary_str = f"{currency}{amount:,}/{interval}"

    url = (
        j.get("jobUrl") or
        j.get("job_url") or
        j.get("jobPostingUrl") or
        ""
    )

    company = j.get("companyName") or j.get("company_name") or j.get("company") or ""
    date    = j.get("datePosted") or j.get("date_posted") or ""
    job_id  = str(j.get("id") or "")
    platform = j.get("site") or "ever-jobs"

    return Job(
        title=j.get("title", ""),
        company=company,
        location=location_str,
        url=url,
        platform=platform,
        description=j.get("description", ""),
        salary=salary_str,
        posted_date=date,
        job_id=job_id,
    )