Prep reads remote from a Danish or Swedish place line, and from a search role's title
The search providers stop mapping remote_word themselves (R2), so prep reads the same words: in any role's place line after remote_of, and in the title of a role from a search. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d04ceae7e0
commit
56fad284a6
4 files changed
+48
-6
No files matched your search
+3
-2
@@ -85,8 +85,9 @@ def map_role(row: Mapping[str, Any], gaz: places.Gazetteer, folds: Mapping[str,
|
|||||||
"seniority_title": titled,
|
"seniority_title": titled,
|
||||||
"employment": words.employment(host, row["employment_host"], tables),
|
"employment": words.employment(host, row["employment_host"], tables),
|
||||||
"remote": words.remote(host, row["remote_host"] or None, (), "", tables),
|
"remote": words.remote(host, row["remote_host"] or None, (), "", tables),
|
||||||
"remote_places": words.remote(host, None, _places(row["raw_places"]), row["place"],
|
"remote_places": words.remote(
|
||||||
tables),
|
host, None, _places(row["raw_places"]), row["place"], tables,
|
||||||
|
title=row["title"] if row["source"] == "search" else ""),
|
||||||
"country": country(gaz, place_ids, row["country_host"]),
|
"country": country(gaz, place_ids, row["country_host"]),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+24
-3
@@ -44,6 +44,23 @@ def _match(rules: Mapping[str, Any], key: str) -> str | None:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
#: Remote and hybrid in a line of Danish, Swedish or English that `remote_of`
|
||||||
|
#: does not read: "Nordhavn og mulighed for hjemmearbejde", "Arbete på distans".
|
||||||
|
#: Remote first, since "fuldt hjemmearbejde" is remote.
|
||||||
|
_REMOTE_LINE = re.compile(
|
||||||
|
r"\bremote\b|fjernarbejde|fuldt hjemmearbejde|distansarbete|på distans", re.IGNORECASE)
|
||||||
|
_HYBRID_LINE = re.compile(r"\bhybrid|hjemmearbejde", re.IGNORECASE)
|
||||||
|
|
||||||
|
|
||||||
|
def _line_word(text: str) -> str:
|
||||||
|
"""`remote_of`'s reading of a line, else its Danish and Swedish words."""
|
||||||
|
if found := remote_of(text):
|
||||||
|
return found
|
||||||
|
if _REMOTE_LINE.search(text):
|
||||||
|
return "remote"
|
||||||
|
return "hybrid" if _HYBRID_LINE.search(text) else ""
|
||||||
|
|
||||||
|
|
||||||
def _squash(word: str) -> str:
|
def _squash(word: str) -> str:
|
||||||
return "".join(c for c in word.lower() if c not in " -_")
|
return "".join(c for c in word.lower() if c not in " -_")
|
||||||
|
|
||||||
@@ -86,7 +103,7 @@ def _place_text(place: Any) -> str:
|
|||||||
|
|
||||||
|
|
||||||
def remote(host: str, value: Any, places: Iterable[Any] = (), line: str = "",
|
def remote(host: str, value: Any, places: Iterable[Any] = (), line: str = "",
|
||||||
tables: Tables = TABLES) -> str:
|
tables: Tables = TABLES, title: str = "") -> str:
|
||||||
"""How the role is worked, one of `REMOTE` or ''.
|
"""How the role is worked, one of `REMOTE` or ''.
|
||||||
|
|
||||||
`value` is the host's own (a bool, or its word; `host_word`'s 'true' and
|
`value` is the host's own (a bool, or its word; `host_word`'s 'true' and
|
||||||
@@ -95,7 +112,9 @@ def remote(host: str, value: Any, places: Iterable[Any] = (), line: str = "",
|
|||||||
every role that is not remote, hybrid ones included. A word goes
|
every role that is not remote, hybrid ones included. A word goes
|
||||||
through the host's table, else the shared map. When the value says
|
through the host's table, else the shared map. When the value says
|
||||||
nothing, the place line or the place texts are read for a word
|
nothing, the place line or the place texts are read for a word
|
||||||
(`remote_of`: "Hybrid, Berlin"), and last a place the reader marked
|
(`remote_of`: "Hybrid, Berlin", and the Danish and Swedish words), then
|
||||||
|
`title` when given, which the stage gives for a search provider's role
|
||||||
|
only ("Backend Developer - Remote"), and last a place the reader marked
|
||||||
remote is remote."""
|
remote is remote."""
|
||||||
if value is True or value == "true":
|
if value is True or value == "true":
|
||||||
return "remote"
|
return "remote"
|
||||||
@@ -103,7 +122,9 @@ def remote(host: str, value: Any, places: Iterable[Any] = (), line: str = "",
|
|||||||
if said and (found := lookup("remote", host, str(value), tables)):
|
if said and (found := lookup("remote", host, str(value), tables)):
|
||||||
return found
|
return found
|
||||||
places = list(places)
|
places = list(places)
|
||||||
if found := remote_of(line or "; ".join(map(_place_text, places))):
|
if found := _line_word(line or "; ".join(map(_place_text, places))):
|
||||||
|
return found
|
||||||
|
if title and (found := _line_word(title)):
|
||||||
return found
|
return found
|
||||||
if any(isinstance(p, Mapping) and p.get("remote") is True for p in places):
|
if any(isinstance(p, Mapping) and p.get("remote") is True for p in places):
|
||||||
return "remote"
|
return "remote"
|
||||||
|
|||||||
@@ -1273,7 +1273,7 @@ class Store:
|
|||||||
due (`prep_due` above 0), every open role, or every role."""
|
due (`prep_due` above 0), every open role, or every role."""
|
||||||
where = {"due": "prep_due > 0", "open": "closed_at IS NULL", "all": "1"}[scope]
|
where = {"due": "prep_due > 0", "open": "closed_at IS NULL", "all": "1"}[scope]
|
||||||
return self._rows(
|
return self._rows(
|
||||||
f"""SELECT uid, prep_due, {_HOST} AS host, title, company, company_key, place,
|
f"""SELECT uid, prep_due, source, {_HOST} AS host, title, company, company_key, place,
|
||||||
seniority_host, employment_host, remote_host, country_host,
|
seniority_host, employment_host, remote_host, country_host,
|
||||||
seniority_model, seniority_stated, seniority_title, seniority,
|
seniority_model, seniority_stated, seniority_title, seniority,
|
||||||
employment, remote, country,
|
employment, remote, country,
|
||||||
|
|||||||
@@ -93,6 +93,26 @@ def test_remote_from_a_bool_a_word_the_place_line_then_a_place_marked_remote() -
|
|||||||
"", TABLES) == "remote"
|
"", TABLES) == "remote"
|
||||||
|
|
||||||
|
|
||||||
|
def test_a_line_in_danish_or_swedish_and_a_search_title_are_read() -> None:
|
||||||
|
assert words.remote("jobindex", None, (), "Nordhavn og mulighed for hjemmearbejde") \
|
||||||
|
== "hybrid"
|
||||||
|
assert words.remote("jobindex", None, (), "Aarhus, fuldt hjemmearbejde") == "remote"
|
||||||
|
assert words.remote("platsbanken", None, (), "Malmö, arbete på distans") == "remote"
|
||||||
|
assert words.remote("adzuna", None, (), "Berlin", title="Backend Developer - Remote") \
|
||||||
|
== "remote"
|
||||||
|
assert words.remote("adzuna", None, (), "Berlin", title="Backend Developer") == ""
|
||||||
|
|
||||||
|
|
||||||
|
def test_a_search_roles_title_counts_and_a_boards_does_not(store: Store) -> None:
|
||||||
|
store.upsert_role(item("1", title="Engineer (remote)", place="Berlin"))
|
||||||
|
store.upsert_role(item("2", title="Engineer (remote)", place="Berlin", host="jobindex",
|
||||||
|
provider="jobindex"))
|
||||||
|
with store.transaction() as conn:
|
||||||
|
conn.execute("UPDATE roles SET source = 'search' WHERE source_id = 'jobindex:2'")
|
||||||
|
prep.run(store, tables=TABLES)
|
||||||
|
assert (row(store, "1")["remote"], row(store, "2", "jobindex")["remote"]) == ("", "remote")
|
||||||
|
|
||||||
|
|
||||||
# ----------------------------------------------------------------- country
|
# ----------------------------------------------------------------- country
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
|||||||
Reference in new issue
Block a user