Unpack structured pay from five ATS hosts; fix the function classifier
Part A: Ashby (?includeCompensation=true), Greenhouse (pay_transparency=true, already free on the list request), Lever (salaryRange), Recruitee (salary) and Personio (salaryInformation) all give structured pay; Workable and SmartRecruiters do not (checked live). Every host converts to a yearly salary_min/salary_max/currency, multiplying a monthly figure by 12 and skipping an hourly or daily one rather than annualising a number nobody stated. A range with no currency is ignored, and Greenhouse's own multi-zone ranges are skipped outright since nothing says which zone the role is at. Part B: classify() matched substrings, so " it" matched inside "Italy", filing European sales roles as engineering; it now matches on word boundaries (full boundary for the handful of short tokens that are themselves the start of an unrelated word, prefix matching kept for the stems). Title is checked before department (a hand-checked sample found title-first right about twice as often), nothing matching returns '' rather than "other", and a modest set of German/Dutch/Danish/Norwegian/Swedish/ French keywords covers the seed's other languages. function is not a board field, so it gets the opposite rule from every other raw column: extract's answer overwrites the classifier's guess outright, and once extracted_at is set no later pull may put the guess back. Migration 9 recomputes function for every not-yet-extracted role from its stored title and department. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0558ef19ed
commit
44ff7c0131
10 files changed
+458
-35
No files matched your search
+101
-5
@@ -40,6 +40,16 @@ def test_greenhouse_parses_titles_locations_and_html_description() -> None:
|
||||
assert first["remote"] is None
|
||||
|
||||
|
||||
def test_greenhouse_reads_pay_input_ranges_and_skips_an_hourly_one() -> None:
|
||||
rows = _rows("greenhouse")
|
||||
assert (rows[0]["salary_min"], rows[0]["salary_max"], rows[0]["currency"]) == \
|
||||
(65000, 85000, "EUR")
|
||||
# "SF Bay Area Hourly Rate" is skipped: a yearly figure invented from an
|
||||
# hourly one would be wrong.
|
||||
assert (rows[1]["salary_min"], rows[1]["salary_max"], rows[1]["currency"]) == \
|
||||
(None, None, "")
|
||||
|
||||
|
||||
def test_lever_parses_categories_and_workplace_type() -> None:
|
||||
rows = _rows("lever")
|
||||
assert [r["source_id"] for r in rows] == ["2001", "2002"]
|
||||
@@ -51,6 +61,14 @@ def test_lever_parses_categories_and_workplace_type() -> None:
|
||||
assert rows[1]["posted"] is None
|
||||
|
||||
|
||||
def test_lever_reads_salary_range_and_skips_an_hourly_wage() -> None:
|
||||
rows = _rows("lever")
|
||||
assert (rows[0]["salary_min"], rows[0]["salary_max"], rows[0]["currency"]) == \
|
||||
(90000, 120000, "EUR")
|
||||
assert (rows[1]["salary_min"], rows[1]["salary_max"], rows[1]["currency"]) == \
|
||||
(None, None, "")
|
||||
|
||||
|
||||
def test_ashby_parses_is_remote_and_compensation() -> None:
|
||||
rows = _rows("ashby")
|
||||
assert [r["source_id"] for r in rows] == ["3001", "3002"]
|
||||
@@ -59,6 +77,16 @@ def test_ashby_parses_is_remote_and_compensation() -> None:
|
||||
assert rows[1]["remote"] is True
|
||||
|
||||
|
||||
def test_ashby_reads_summary_components_only_with_includecompensation() -> None:
|
||||
# summaryComponents only appears with ?includeCompensation=true on the
|
||||
# feed URL (see _BOARDS); the second job has no compensation key at all.
|
||||
rows = _rows("ashby")
|
||||
assert (rows[0]["salary_min"], rows[0]["salary_max"], rows[0]["currency"]) == \
|
||||
(70000, 90000, "EUR")
|
||||
assert (rows[1]["salary_min"], rows[1]["salary_max"], rows[1]["currency"]) == \
|
||||
(None, None, "")
|
||||
|
||||
|
||||
def test_workable_builds_the_job_url_and_reads_location_and_remote() -> None:
|
||||
rows = _rows("workable", slug="huggingface")
|
||||
assert [r["source_id"] for r in rows] == ["6125026", "6125041"]
|
||||
@@ -85,6 +113,10 @@ def test_recruitee_parses_salary_bounds_and_careers_url() -> None:
|
||||
assert rows[0]["url"] == "https://acme.example/o/player-support-agent-german-1"
|
||||
assert rows[0]["salary"] == "35000-45000 EUR"
|
||||
assert rows[1]["salary"] == ""
|
||||
assert (rows[0]["salary_min"], rows[0]["salary_max"], rows[0]["currency"]) == \
|
||||
(35000, 45000, "EUR")
|
||||
assert (rows[1]["salary_min"], rows[1]["salary_max"], rows[1]["currency"]) == \
|
||||
(None, None, "")
|
||||
|
||||
|
||||
def test_personio_builds_the_job_url_and_reads_cdata_description() -> None:
|
||||
@@ -96,16 +128,80 @@ def test_personio_builds_the_job_url_and_reads_cdata_description() -> None:
|
||||
assert rows[1]["remote"] is None # "Munich"
|
||||
|
||||
|
||||
def test_personio_reads_salary_information_when_present() -> None:
|
||||
rows = _rows("personio", slug="acme")
|
||||
assert (rows[0]["salary_min"], rows[0]["salary_max"], rows[0]["currency"]) == \
|
||||
(42000, 55000, "EUR")
|
||||
assert (rows[1]["salary_min"], rows[1]["salary_max"], rows[1]["currency"]) == \
|
||||
(None, None, "")
|
||||
|
||||
|
||||
# ------------------------------------------------------------ salary math
|
||||
|
||||
def test_yearly_amount_converts_a_monthly_range_by_12() -> None:
|
||||
assert ats._yearly_amount(3000, 4000, "eur", "month", {"year": 1, "month": 12}) == \
|
||||
(36000, 48000, "EUR")
|
||||
|
||||
|
||||
def test_yearly_amount_ignores_a_range_with_no_currency() -> None:
|
||||
assert ats._yearly_amount(3000, 4000, "", "year", {"year": 1, "month": 12}) == \
|
||||
(None, None, "")
|
||||
|
||||
|
||||
def test_yearly_amount_skips_an_interval_outside_the_factor_table() -> None:
|
||||
# An hourly or a daily rate: a yearly figure invented from it would be
|
||||
# wrong, so it is left out rather than multiplied by a guess.
|
||||
assert ats._yearly_amount(20, 30, "usd", "hour", {"year": 1, "month": 12}) == \
|
||||
(None, None, "")
|
||||
|
||||
|
||||
def test_greenhouse_salary_skips_more_than_one_range() -> None:
|
||||
# Several ranges (one per office/zone) give no way to tell which one the
|
||||
# role in hand is at, so all of them are left out rather than guessed.
|
||||
ranges = [
|
||||
{"min_cents": 100000, "max_cents": 200000, "currency_type": "EUR", "title": "Zone 1"},
|
||||
{"min_cents": 90000, "max_cents": 180000, "currency_type": "EUR", "title": "Zone 2"},
|
||||
]
|
||||
assert ats._greenhouse_salary(ranges) == (None, None, "")
|
||||
|
||||
|
||||
# --------------------------------------------------------------- classify
|
||||
|
||||
def test_classify_matches_department_before_title() -> None:
|
||||
assert ats.classify("Engineering", "Marketing Lead") == "engineering"
|
||||
assert ats.classify("", "Senior Backend Engineer") == "engineering"
|
||||
def test_classify_matches_title_before_department() -> None:
|
||||
# A specific title beats a generic department (see classify's docstring
|
||||
# for the hand-checked sample this is based on).
|
||||
assert ats.classify("Engineering", "Marketing Lead") == "marketing"
|
||||
assert ats.classify("Operations", "Senior Backend Engineer") == "engineering"
|
||||
assert ats.classify("", "Product Manager, Payments") == "product"
|
||||
assert ats.classify("", "Data Product Manager") == "product"
|
||||
assert ats.classify("", "Machine Learning Engineer") == "data"
|
||||
assert ats.classify("", "Executive Assistant to the CEO") == "finance/legal/ops"
|
||||
assert ats.classify("", "") == "other"
|
||||
# The department is still the fallback when the title matches nothing.
|
||||
assert ats.classify("Engineering", "") == "engineering"
|
||||
# Nothing matches either: '', not "other", which would claim a
|
||||
# knowledge the classifier does not have.
|
||||
assert ats.classify("", "") == ""
|
||||
assert ats.classify("", "Chief Bottle Washer") == ""
|
||||
|
||||
|
||||
def test_classify_matches_whole_words_not_substrings() -> None:
|
||||
# "it" used to match inside "Italy"/"Italia" ("IT" meant the department,
|
||||
# not the country), filing a sales role as engineering.
|
||||
assert ats.classify("Commercial Italy", "Account Manager - Liguria") == "sales"
|
||||
assert ats.classify("IT", "") == "engineering"
|
||||
assert ats.classify("", "Marketing Lead, Seoul") == "marketing"
|
||||
# A stem still matches its suffixed forms: "Engineering" the department,
|
||||
# not just "engineer" the exact word.
|
||||
assert ats.classify("Engineering", "") == "engineering"
|
||||
assert ats.classify("", "Software Developers") == "engineering"
|
||||
|
||||
|
||||
def test_classify_understands_a_modest_set_of_other_languages() -> None:
|
||||
assert ats.classify("", "Senior Entwickler (m/w/d)") == "engineering"
|
||||
assert ats.classify("", "Vertriebsmitarbeiter (m/w/d)") == "sales"
|
||||
assert ats.classify("", "Ontwikkelaar") == "engineering"
|
||||
assert ats.classify("", "Udvikler") == "engineering"
|
||||
assert ats.classify("", "Ingénieur logiciel") == "engineering"
|
||||
|
||||
|
||||
# ------------------------------------------------------------- allow-list
|
||||
@@ -163,7 +259,7 @@ def test_fetch_rows_retries_greenhouse_without_content_on_a_too_large_body(
|
||||
rows = ats._fetch_rows(object(), "greenhouse:acme") # type: ignore[arg-type]
|
||||
|
||||
assert calls == [
|
||||
"https://boards-api.greenhouse.io/v1/boards/acme/jobs?content=true",
|
||||
"https://boards-api.greenhouse.io/v1/boards/acme/jobs?content=true&pay_transparency=true",
|
||||
"https://boards-api.greenhouse.io/v1/boards/acme/jobs",
|
||||
]
|
||||
assert [r["source_id"] for r in rows] == ["1001", "1002"]
|
||||
|
||||
Reference in new issue
Block a user