Tag a company All roles to read its big boards with the agents' wide reach; favourite scores only
Migration 21 adds companies.all_roles, tags every favourite of any agent and each company whose board had params {"reach": "all"} (logged per board, the param removed). reach.plan reads a tagged company's boards with the union of the enabled agents' require reach and the base reach; favourite no longer widens the fetch. POST /api/companies/{key}/all-roles sets it and queues a pull when on. The Companies list, the reader and the company strip draw the toggle beside the affinity buttons, the list filters on it, and the board's reach editor drops its All roles option.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8d9a059e24
commit
5d5b7e7d3f
20 files changed
+422
-124
No files matched your search
+33
-9
@@ -450,7 +450,8 @@ class CompanyOut(BaseModel):
|
||||
`careers_opened_at` are the Watchlist's (`Company`'s), the latter also
|
||||
when a person last looked at the careers page. `by_hand` marks a company
|
||||
with no board shown that is not `from_search`, and `hand_reason` says why
|
||||
it is read by hand (`app.models.HAND_REASONS`)."""
|
||||
it is read by hand (`app.models.HAND_REASONS`). `all_roles` is the
|
||||
company tag that reads its boards with the agents' wide reach."""
|
||||
|
||||
key: str
|
||||
name: str
|
||||
@@ -473,6 +474,7 @@ class CompanyOut(BaseModel):
|
||||
from_search: bool = False
|
||||
hand_reason: str = ""
|
||||
by_hand: bool = False
|
||||
all_roles: bool = False
|
||||
#: The board's own reach in its params (`jobs.reach.OVERRIDE_KEYS`), and
|
||||
#: what a pull asks its board for (`jobs.reach.line`).
|
||||
reach_params: dict[str, Any] = {}
|
||||
@@ -516,6 +518,7 @@ def _company_outs(store: Store, agent: int | None) -> list[CompanyOut]:
|
||||
failing_since=since, failing_reason=reason,
|
||||
from_search=from_search, hand_reason=c.hand_reason,
|
||||
by_hand=c.key not in boards and not from_search,
|
||||
all_roles=bool(c.all_roles),
|
||||
reach_params={k: v for k, v in (sub.params if sub else {}).items()
|
||||
if k in jobs.reach.OVERRIDE_KEYS},
|
||||
reach=jobs.reach.line(plan, sub) if sub else ""))
|
||||
@@ -712,6 +715,27 @@ def set_watch(key: str, body: WatchBody, store: StoreDep) -> Company:
|
||||
raise HTTPException(404, f"no such company: {key}") from None
|
||||
|
||||
|
||||
class AllRolesBody(BaseModel):
|
||||
on: bool
|
||||
|
||||
|
||||
@router.post("/companies/{key}/all-roles")
|
||||
def set_all_roles(key: str, body: AllRolesBody, store: StoreDep, queue: QueueDep) -> Company:
|
||||
"""Tag a company All roles, or untag it: global, apart from affinity.
|
||||
Its big boards are then read with the agents' wide reach, Europe today,
|
||||
rather than their places (`app/jobs/reach.py`).
|
||||
On queues a pull right after, as the other reopening switches do; off
|
||||
queues nothing and asks nothing first, since no role closes until the
|
||||
next pull reads the board with its filter again. 404 for an unknown key."""
|
||||
try:
|
||||
company = store.set_all_roles(key, body.on)
|
||||
except KeyError:
|
||||
raise HTTPException(404, f"no such company: {key}") from None
|
||||
if body.on:
|
||||
queue.enqueue("pull")
|
||||
return company
|
||||
|
||||
|
||||
class CareersBody(BaseModel):
|
||||
careers_url: str
|
||||
|
||||
@@ -814,9 +838,10 @@ def switch_source(sub_id: int, body: SwitchBody, store: StoreDep,
|
||||
|
||||
|
||||
class ReachBody(BaseModel):
|
||||
#: `agents`: the enabled agents' reach; `all`: every role; `own`: the
|
||||
#: `countries` (ISO codes) and remote given here.
|
||||
mode: Literal["agents", "all", "own"]
|
||||
#: `agents`: the enabled agents' reach; `own`: the `countries` (ISO
|
||||
#: codes) and remote given here. Every role is the company's All roles
|
||||
#: tag (`/api/companies/{key}/all-roles`), not a board's reach.
|
||||
mode: Literal["agents", "own"]
|
||||
countries: list[str] = []
|
||||
remote: bool = False
|
||||
|
||||
@@ -826,7 +851,8 @@ def set_reach(sub_id: int, body: ReachBody, store: StoreDep) -> dict[str, Any]:
|
||||
"""A board's own reach, which wins over the agents' (see
|
||||
`app/jobs/reach.py`), or none. The next pull reads the board so; a
|
||||
narrower reach closes the roles outside it then, except those with a
|
||||
vote or an application."""
|
||||
vote or an application. A company tagged All roles reads every role
|
||||
whatever its board's reach says."""
|
||||
sub = store.subscription(sub_id)
|
||||
if sub is None or sub.source != "ats":
|
||||
raise HTTPException(404, f"no such board: {sub_id}")
|
||||
@@ -834,11 +860,9 @@ def set_reach(sub_id: int, body: ReachBody, store: StoreDep) -> dict[str, Any]:
|
||||
if unknown := [c for c in codes if not places.known(f"country:{c}") or c == "EU"]:
|
||||
raise HTTPException(422, f"Not a country code: {', '.join(unknown)}.")
|
||||
if body.mode == "own" and not (codes or body.remote):
|
||||
raise HTTPException(422, "Name a country or remote, or read all roles.")
|
||||
raise HTTPException(422, "Name a country or remote, or take the agents' reach.")
|
||||
params = {k: v for k, v in sub.params.items() if k not in jobs.reach.OVERRIDE_KEYS}
|
||||
if body.mode == "all":
|
||||
params["reach"] = "all"
|
||||
elif body.mode == "own":
|
||||
if body.mode == "own":
|
||||
params |= {"countries": codes, "remote": body.remote}
|
||||
sub = store.update_subscription(sub_id, params=params)
|
||||
return {"source": _one_source(store, sub_id),
|
||||
|
||||
Reference in new issue
Block a user