Hosts a to l declare READS: places, teaser, stated seniority and employment
Ashby, BambooHR, Deel, Eightfold, Gem, Greenhouse, HiBob, HR Manager, Jibe, Jobylon and Lever move to feed_url(slug, ask) and page(get, slug, cursor, ask), declare READS with the robots decision, and drop robots_page. Rows carry places (Ashby secondaryLocations, Lever allLocations, Greenhouse offices in place of a Hybrid placeholder), Jobylon keeps its summary as teaser and maps experience and employment, Eightfold reads creationTs as the posting date and Ashby reads workplaceType. Fixtures <name>-places.* and jobylon-teaser.html drive the conformance checks; the eleven names leave UNDECLARED. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4c0da58da7
commit
f2e652a8da
35 files changed
+1290
-391
No files matched your search
@@ -8,12 +8,17 @@ The field map is ported from `openings.go` in
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import logging
|
||||
import re
|
||||
from collections.abc import Callable
|
||||
from typing import Any
|
||||
|
||||
from desk.sources import strip_html
|
||||
|
||||
from ._shared import Row, is_web_url, num, only, parse_dt, path_slug_ok, pay_line, yearly_amount
|
||||
from ._contract import Ask, Fields, Place, Reads, Row
|
||||
from ._shared import is_web_url, num, only, parse_dt, path_slug_ok, pay_line, yearly_amount
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
NAME = "ashby"
|
||||
LABEL = "Ashby"
|
||||
@@ -23,8 +28,23 @@ PATTERNS = (
|
||||
r"api\.ashbyhq\.com/posting-api/job-board/([A-Za-z0-9_.-]+)",
|
||||
)
|
||||
|
||||
READS = Reads(
|
||||
scope="board", listing="whole", text="listing", complete="whole",
|
||||
places="many", empty="suspect",
|
||||
fields=Fields(pay="figures", posted="trusted", remote="stated", employment="stated"),
|
||||
robots="api: no robots.txt check needed (public board API), 2026-09-30",
|
||||
)
|
||||
|
||||
_API = "api.ashbyhq.com"
|
||||
|
||||
#: `workplaceType` -> `store._remote`'s words. `isRemote` is true for hybrid
|
||||
#: roles too, so it is only the fallback when the role has no `workplaceType`.
|
||||
_WORKPLACE = {"remote": "remote", "hybrid": "hybrid", "onsite": "onsite"}
|
||||
|
||||
#: `employmentType` -> the app's employment words.
|
||||
_EMPLOYMENT = {"fulltime": "full_time", "parttime": "part_time", "intern": "intern",
|
||||
"contract": "contract", "temporary": "temporary"}
|
||||
|
||||
|
||||
def slug_ok(slug: str) -> bool:
|
||||
return path_slug_ok(slug)
|
||||
@@ -38,7 +58,7 @@ def careers_url(slug: str) -> str:
|
||||
return f"https://jobs.ashbyhq.com/{slug}"
|
||||
|
||||
|
||||
def feed_url(slug: str) -> str:
|
||||
def feed_url(slug: str, ask: Ask) -> str:
|
||||
return f"https://{_API}/posting-api/job-board/{slug}?includeCompensation=true"
|
||||
|
||||
|
||||
@@ -94,6 +114,32 @@ def _salary_text(compensation: dict[str, Any]) -> str:
|
||||
or compensation.get("scrapeableCompensationSalarySummary") or "")
|
||||
|
||||
|
||||
def _places(j: dict[str, Any], workplace: str | None) -> list[Place]:
|
||||
"""The primary `location`, then each of `secondaryLocations`, in the host's
|
||||
words. The primary is remote or an office as `workplaceType` says; a
|
||||
place that names itself remote is remote."""
|
||||
primary = (j.get("location") or "").strip()
|
||||
named = [(primary, {"remote": True, "hybrid": False, "onsite": False}.get(workplace or ""))]
|
||||
named += [(str((s or {}).get("location") or "").strip(), None)
|
||||
for s in j.get("secondaryLocations") or []]
|
||||
out: list[Place] = []
|
||||
for text, remote in named:
|
||||
if text and text not in (p["text"] for p in out):
|
||||
out.append({"text": text, "remote": True if re.search(r"\bremote\b", text, re.I)
|
||||
else remote})
|
||||
return out
|
||||
|
||||
|
||||
def _employment(value: Any) -> str | None:
|
||||
word = str(value or "").strip()
|
||||
if not word:
|
||||
return None
|
||||
found = _EMPLOYMENT.get(word.lower())
|
||||
if found is None:
|
||||
log.debug("ashby: unknown employmentType %r", word)
|
||||
return found
|
||||
|
||||
|
||||
def parse(body: bytes, slug: str) -> list[Row]:
|
||||
data = json.loads(body)
|
||||
rows = []
|
||||
@@ -105,18 +151,24 @@ def parse(body: bytes, slug: str) -> list[Row]:
|
||||
description = j.get("descriptionHtml") or j.get("descriptionPlain") or ""
|
||||
compensation = j.get("compensation") or {}
|
||||
salary_min, salary_max, currency = _salary(compensation.get("summaryComponents") or [])
|
||||
rows.append({
|
||||
workplace = _WORKPLACE.get(str(j.get("workplaceType") or "").strip().lower())
|
||||
places = _places(j, workplace)
|
||||
row: Row = {
|
||||
"source_id": str(j.get("id") or ""),
|
||||
"title": title,
|
||||
"location": (j.get("location") or "").strip(),
|
||||
"places": places,
|
||||
"location": "; ".join(p["text"] for p in places),
|
||||
"url": url,
|
||||
"posted": parse_dt(j.get("publishedAt")),
|
||||
"department": (j.get("department") or j.get("team") or "").strip(),
|
||||
"description": strip_html(description),
|
||||
"remote": j.get("isRemote"),
|
||||
"remote": workplace or j.get("isRemote"),
|
||||
"salary_text": _salary_text(compensation),
|
||||
"salary_min": salary_min,
|
||||
"salary_max": salary_max,
|
||||
"currency": currency,
|
||||
})
|
||||
}
|
||||
if employment := _employment(j.get("employmentType")):
|
||||
row["employment"] = employment
|
||||
rows.append(row)
|
||||
return rows
|
||||
Reference in new issue
Block a user