Share the readers' place, table-lookup and country helpers, unify the employment vocabulary, and list the enrich switch with the stages
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ca80219bbb
commit
903b69b6d3
34 files changed
+290
-207
No files matched your search
+7
-11
@@ -27,7 +27,7 @@ from typing import Any
|
||||
from desk.sources import strip_html
|
||||
|
||||
from ._contract import Ask, Fields, Place, Reads, Row
|
||||
from ._shared import Get, Page, only, parse_dt
|
||||
from ._shared import Get, Page, add_place, only, parse_dt, table_word
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@@ -69,9 +69,9 @@ DETAIL_QUERY = (
|
||||
_REMOTE = {"IN_OFFICE": "onsite", "HYBRID": "hybrid", "REMOTE": "remote"}
|
||||
|
||||
#: `job.employmentType` -> the app's employment words.
|
||||
_EMPLOYMENT = {"FULL_TIME": "full_time", "PART_TIME": "part_time", "CONTRACT": "contract",
|
||||
"CONTRACTOR": "contract", "INTERN": "intern", "INTERNSHIP": "intern",
|
||||
"TEMPORARY": "temporary", "FREELANCE": "freelance"}
|
||||
_EMPLOYMENT = {"full_time": "full_time", "part_time": "part_time", "contract": "contract",
|
||||
"contractor": "contract", "intern": "internship", "internship": "internship",
|
||||
"temporary": "temporary", "freelance": "freelance"}
|
||||
|
||||
|
||||
def slug_ok(slug: str) -> bool:
|
||||
@@ -131,8 +131,7 @@ def rows(postings: list[dict[str, Any]], slug: str) -> list[Row]:
|
||||
places: list[Place] = []
|
||||
for loc in locations:
|
||||
text = str(loc.get("city") or loc.get("name") or "").strip()
|
||||
if text and text not in (pl["text"] for pl in places):
|
||||
places.append({"text": text, "remote": loc["isRemote"]
|
||||
add_place(places, {"text": text, "remote": loc["isRemote"]
|
||||
if isinstance(loc.get("isRemote"), bool) else None})
|
||||
job = p.get("job") or {}
|
||||
remote = _REMOTE.get(str(job.get("locationType") or "").upper())
|
||||
@@ -150,11 +149,8 @@ def rows(postings: list[dict[str, Any]], slug: str) -> list[Row]:
|
||||
"remote": remote,
|
||||
"salary_text": "",
|
||||
}
|
||||
if word := str(job.get("employmentType") or "").strip().upper():
|
||||
if employment := _EMPLOYMENT.get(word):
|
||||
row["employment"] = employment
|
||||
else:
|
||||
log.debug("gem: unknown employmentType %r", word)
|
||||
if employment := table_word(_EMPLOYMENT, job.get("employmentType"), log, "employmentType"):
|
||||
row["employment"] = employment
|
||||
out.append(row)
|
||||
return out
|
||||
|
||||
|
||||
Reference in new issue
Block a user