Keep a board's stated pay as salary_text, even when it does not normalise
Every ats parser now writes one human-readable pay line whether or not it
converts to yearly salary_min/salary_max/currency: hourly and daily rates,
Greenhouse's several pay zones, and a range with no currency all survive as
text instead of being dropped outright. Stored in roles.salary_text
(migration 12), replaced whole on every pull like title, so a board that
stops stating pay clears it rather than leaving a stale line. salary_state
is derived, not stored ('normalised', 'stated', or ''), and is what the
feed's new Pay filter and badge read; gates and scoring are unchanged, still
reading only the normalised columns.
Co-Authored-By: Claude Sonnet <noreply@anthropic.com>
This commit is contained in:
1 parent
706b127bc0
commit
fa4e1a657f
18 files changed
+528
-57
No files matched your search
@@ -88,6 +88,30 @@ def test_list_roles_filters_by_query_place_and_function(
|
||||
assert [r["source_id"] for r in res.json()["items"]] == ["3"]
|
||||
|
||||
|
||||
def test_list_roles_exposes_and_filters_by_pay(client: TestClient, store: Store) -> None:
|
||||
"""`salary_text` and `salary_state` (app/models.py) are on every role the
|
||||
API serves, and `pay` (`Store.PAY`) filters the feed by it, in SQL before
|
||||
`limit` like the other filters."""
|
||||
store.upsert_role(posting("normalised", salary_min=70000, salary_max=90000,
|
||||
currency="EUR", salary_text="EUR 70,000 to 90,000 per year"))
|
||||
store.upsert_role(posting("stated", salary_text="USD 45 to 60 per hour"))
|
||||
store.upsert_role(posting("none"))
|
||||
|
||||
items = {r["source_id"]: r for r in client.get("/api/roles").json()["items"]}
|
||||
assert items["normalised"]["salary_text"] == "EUR 70,000 to 90,000 per year"
|
||||
assert items["normalised"]["salary_state"] == "normalised"
|
||||
assert items["stated"]["salary_state"] == "stated"
|
||||
assert items["none"]["salary_state"] == ""
|
||||
|
||||
res = client.get("/api/roles", params={"pay": "stated"})
|
||||
assert {r["source_id"] for r in res.json()["items"]} == {"normalised", "stated"}
|
||||
res = client.get("/api/roles", params={"pay": "normalised"})
|
||||
assert [r["source_id"] for r in res.json()["items"]] == ["normalised"]
|
||||
res = client.get("/api/roles", params={"pay": "stated_only"})
|
||||
assert [r["source_id"] for r in res.json()["items"]] == ["stated"]
|
||||
assert client.get("/api/roles", params={"pay": "bogus"}).status_code == 422
|
||||
|
||||
|
||||
def test_list_roles_limit_is_bounded(client: TestClient, store: Store) -> None:
|
||||
for i in range(3):
|
||||
store.upsert_role(posting(str(i)))
|
||||
|
||||
Reference in new issue
Block a user