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:
WolfandClaude Opus 5.5 committed 2026-09-30 10:44:41 +02:00
1 parent 8d9a059e24
commit 5d5b7e7d3f
20 files changed
+422 -124

No files matched your search

+50 -46
View File
@@ -10,21 +10,23 @@ on. Computed once per pull (`plan`) and handed to each board's batch as the
function, a remote value other than `remote`, a place the gazetteer does
not know), can take a role from anywhere, so the base reach is then
everywhere.
- **Favourite companies** (affinity 2, which skips the `any` gates in
scoring) are read with the `require` reach of the agent that starred them:
the intersection of its `require` gates on country and place, Europe
today, expanded to its countries through the gazetteer. A company is
starred per agent, so its reach is the union over the enabled agents of
the `require` reach where it is a favourite and the `any` reach where not.
- **Wide reach, for the companies tagged All roles** (`companies.all_roles`,
global): the union over the enabled agents of their `require` reach, the
intersection of each one's `require` gates on country and place, Europe
today, expanded to its countries through the gazetteer, and the base
reach, so a tag never reads less than the board would untagged. An agent
with no `require` gate on place makes it everywhere. A role in Freiburg
may be open to remote, or worth asking the company about for Denmark.
Favourite (affinity 2) is scoring only, where it skips the `any` gates; it
does not widen what is fetched.
- **Board override**: a board whose subscription `params` name a country, a
place, remote or `{"reach": "all"}` gets no reach here; `ask_for` reads the
params instead.
place or remote gets no reach here; `ask_for` reads the params instead.
- **Small boards**: a board that listed under `SMALL` roles when last read
whole gets no filter; filtering it saves little and risks closing roles.
A reach of more countries than a `one`-filter host should be asked one by
one (a favourite's Europe on SmartRecruiters) is dropped by `ask_for`, which
knows the reader (`MAX_SERIES`).
one (the wide reach's Europe on SmartRecruiters) is dropped by `ask_for`,
which knows the reader (`MAX_SERIES`), so such a board is read whole.
"""
from __future__ import annotations
@@ -48,7 +50,9 @@ SMALL = 300
SIZE = "ats:size:"
#: The params that make a board's own reach (see `_runner._PARAM_DIMENSION`).
OVERRIDE_KEYS = frozenset(("countries", "country", "places", "place", "remote", "reach"))
OVERRIDE_KEYS = frozenset(("countries", "country", "places", "place", "remote"))
@dataclass(frozen=True)
@@ -160,16 +164,19 @@ def require_reach(agent: Agent, gaz: places.Gazetteer) -> Reach:
@dataclass
class Plan:
"""The reach of one pull: `base` for every board, `favourites` for the
companies some agent starred, and each board's size by target."""
"""The reach of one pull: `base` for every board, `wide` for the boards
of the companies in `tagged` (tagged All roles), and each board's size
by target."""
base: Reach
favourites: dict[str, Reach] = field(default_factory=dict)
wide: Reach = EVERYWHERE
sizes: dict[str, int] = field(default_factory=dict)
tagged: frozenset[str] = frozenset()
def why(self, sub: Subscription) -> tuple[Reach, str]:
"""The reach `sub` is read with, and why: `override`, `small`,
`unknown` (a board never read whole), `favourite` or `agents`."""
`unknown` (a board never read whole), `tag` (its company is tagged
All roles) or `agents`."""
if OVERRIDE_KEYS & set(sub.params or {}):
return EVERYWHERE, "override"
size = self.sizes.get(sub.target)
@@ -177,9 +184,8 @@ class Plan:
return EVERYWHERE, "unknown"
if size < SMALL:
return EVERYWHERE, "small"
key = company_key(sub.company or sub.label)
if key in self.favourites:
return self.favourites[key], "favourite"
if company_key(sub.company or sub.label) in self.tagged:
return self.wide, "tag"
return self.base, "agents"
def for_subscription(self, sub: Subscription) -> dict[str, Any] | None:
@@ -204,29 +210,22 @@ def sizes(store: Store, subs: Iterable[Subscription]) -> dict[str, int]:
def plan(store: Store, subs: Iterable[Subscription] | None = None) -> Plan:
"""The reach of a pull, from the enabled agents and their favourites, and
the sizes of `subs` (every `ats` subscription when None)."""
"""The reach of a pull, from the enabled agents and the companies tagged
All roles, and the sizes of `subs` (every `ats` subscription when
None)."""
gaz = store.gazetteer()
agents = store.agents(enabled_only=True)
reaches = {a.id: (any_reach(a, gaz), require_reach(a, gaz)) for a in agents}
base = NOWHERE
for any_of, _ in reaches.values():
base = base | any_of
if not agents:
base = EVERYWHERE
starred: dict[str, set[int]] = {}
base = wide = NOWHERE
for agent in agents:
for company in store.companies(agent.id):
if company.affinity == 2:
starred.setdefault(company.key, set()).add(agent.id)
favourites: dict[str, Reach] = {}
for key, by in starred.items():
reach = NOWHERE
for agent_id, (any_of, required) in reaches.items():
reach = reach | (required if agent_id in by else any_of)
favourites[key] = reach
base = base | any_reach(agent, gaz)
wide = wide | require_reach(agent, gaz)
if not agents:
base = wide = EVERYWHERE
subs = list(store.subscriptions(source="ats") if subs is None else subs)
return Plan(base, favourites, sizes(store, subs))
tagged = frozenset(c.key for c in store.companies() if c.all_roles)
# A tag never reads less than the board would untagged: the base's
# remote, which a `require` of Europe does not name, is kept.
return Plan(base, wide | base, sizes(store, subs), tagged)
def reaches(store: Store, subs: Iterable[Subscription]) -> Mapping[str, dict[str, Any]]:
@@ -239,14 +238,18 @@ def reaches(store: Store, subs: Iterable[Subscription]) -> Mapping[str, dict[str
#: Why a board is read whole, as the Companies list says it.
_WHOLE = {"small": f"under {SMALL} roles", "unknown": "not read whole yet",
"override": "set here", "favourite": "favourite, too many countries to ask",
"override": "set here", "tag": "company tag, too many countries to ask",
"agents": "an agent takes any place"}
#: Why a board is read filtered, as the Companies list says it.
_SAID = {"override": "set here", "tag": "company tag"}
def line(found: Plan, sub: Subscription) -> str:
"""What a pull asks `sub`'s board for, once its reader has narrowed the
reach, in a few words: "DK, SE, remote · agents", "all roles · under 300
roles", "all roles · Greenhouse cannot filter"."""
reach, in a few words: "DK, SE, remote · agents", "33 countries, remote ·
company tag", "all roles · under 300 roles", "all roles · Greenhouse
cannot filter"."""
module = readers.HOSTS.get(sub.target.partition(":")[0])
if module is None:
return ""
@@ -257,10 +260,11 @@ def line(found: Plan, sub: Subscription) -> str:
else [f"{len(ask.countries)} countries"]
if ask.remote:
words.append("remote")
return f"{', '.join(words)} · {'set here' if why == 'override' else why}"
if why in ("agents", "favourite") and not given.everywhere:
if not module.READS.filters.declared():
return f"all roles · {module.LABEL} cannot filter"
if why == "agents":
return f"all roles · {module.LABEL} cannot ask for these"
return f"{', '.join(words)} · {_SAID.get(why, why)}"
if why in ("agents", "tag") and given.everywhere:
return f"all roles · {'company tag' if why == 'tag' else _WHOLE[why]}"
if why in ("agents", "tag") and not module.READS.filters.declared():
return f"all roles · {module.LABEL} cannot filter"
if why == "agents":
return f"all roles · {module.LABEL} cannot ask for these"
return f"all roles · {_WHOLE[why]}"