Split the All tag into two company overrides: All countries and All roles (WP L)

Fetching has two filters, and a company now overrides each on its own.
All countries (companies.all_countries) is the old All roles tag: its big
boards are read with the agents' wide reach. All roles (companies.all_roles,
new meaning) drops the agents' fetch terms and any later role filter.

- Migration 24 copies the old tag to all_countries and keeps all_roles for
  those companies, and moves a board's {"terms": false} to its company.
- The runner no longer reads {"terms": false}; the plan leaves the terms out
  for a company set to All roles.
- POST /api/companies/{key}/all-countries and /all-roles, each queueing a
  pull when turned on; CompanyOut carries both.
- Two toggles replace All on the Companies row, the reader and the Roles
  strip; the reach line states countries and role types in plain words;
  the filter select gets both options.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Opus 5.5 committed 2026-09-30 12:50:45 +02:00
1 parent 795ca3628c
commit e52857dea5
23 files changed
+602 -215

No files matched your search

+35 -17
View File
@@ -450,8 +450,9 @@ 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`). `all_roles` is the
company tag that reads its boards with the agents' wide reach."""
it is read by hand (`app.models.HAND_REASONS`). `all_countries` and
`all_roles` are the company's two fetch overrides: its big boards read
with the agents' wide reach, and with no role-type narrowing."""
key: str
name: str
@@ -474,6 +475,7 @@ class CompanyOut(BaseModel):
from_search: bool = False
hand_reason: str = ""
by_hand: bool = False
all_countries: 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`).
@@ -518,6 +520,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_countries=bool(c.all_countries),
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},
@@ -715,27 +718,41 @@ def set_watch(key: str, body: WatchBody, store: StoreDep) -> Company:
raise HTTPException(404, f"no such company: {key}") from None
class AllRolesBody(BaseModel):
class OverrideBody(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."""
def _override(store: Store, queue: Any, key: str, on: bool, setter: str) -> Company:
"""Switch one of a company's two fetch overrides. 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 filters again. 404 for an unknown key."""
try:
company = store.set_all_roles(key, body.on)
company = getattr(store, setter)(key, on)
except KeyError:
raise HTTPException(404, f"no such company: {key}") from None
if body.on:
if on:
queue.enqueue("pull")
return company
@router.post("/companies/{key}/all-countries")
def set_all_countries(key: str, body: OverrideBody, store: StoreDep,
queue: QueueDep) -> Company:
"""All countries on or off: global, apart from affinity. On, the
company's big boards are read with the agents' wide reach, Europe today,
rather than their places (`app/jobs/reach.py`). See `_override`."""
return _override(store, queue, key, body.on, "set_all_countries")
@router.post("/companies/{key}/all-roles")
def set_all_roles(key: str, body: OverrideBody, store: StoreDep, queue: QueueDep) -> Company:
"""All roles on or off: global, apart from affinity. On, the company's
boards are read with no role-type narrowing, no fetch terms today
(`app/jobs/reach.py`). See `_override`."""
return _override(store, queue, key, body.on, "set_all_roles")
class CareersBody(BaseModel):
careers_url: str
@@ -839,8 +856,9 @@ def switch_source(sub_id: int, body: SwitchBody, store: StoreDep,
class ReachBody(BaseModel):
#: `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.
#: codes) and remote given here. The wide reach and no role narrowing
#: are the company's overrides (`/api/companies/{key}/all-countries`,
#: `/all-roles`), not a board's reach.
mode: Literal["agents", "own"]
countries: list[str] = []
remote: bool = False
@@ -851,8 +869,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. A company tagged All roles reads every role
whatever its board's reach says."""
vote or an application. A reach set here wins over the company's All
countries override."""
sub = store.subscription(sub_id)
if sub is None or sub.source != "ats":
raise HTTPException(404, f"no such board: {sub_id}")