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:
1 parent
795ca3628c
commit
e52857dea5
23 files changed
+602
-215
No files matched your search
+131
-56
@@ -10,15 +10,15 @@ 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.
|
||||
- **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.
|
||||
- **Wide reach, for the companies set to All countries**
|
||||
(`companies.all_countries`, 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 the override never reads less than the
|
||||
board would without it. 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 or remote gets no reach here; `ask_for` reads the params instead.
|
||||
- **Small boards**: a board that listed under `SMALL` roles when last read
|
||||
@@ -33,12 +33,14 @@ board sends the roles that match one of them rather than every role:
|
||||
|
||||
- The terms of a pull are the union over the enabled agents. An enabled
|
||||
agent with none wants every role, so then there are none.
|
||||
- They go only with the wide reach: a company tagged All roles (`wide` in
|
||||
the reach), and a board whose reach `ask_for` drops as too many countries
|
||||
for a `one` host. The narrow reach (DK, SE) already leaves at most about
|
||||
150 roles on any big board, and small, unknown and overridden boards get
|
||||
no reach at all, so none of those take terms.
|
||||
- A board's params switch them off with `{"terms": false}`.
|
||||
- They go only with the wide reach: a company set to All countries (`wide`
|
||||
in the reach), and a board whose reach `ask_for` drops as too many
|
||||
countries for a `one` host. The narrow reach (DK, SE) already leaves at
|
||||
most about 150 roles on any big board, and small, unknown and overridden
|
||||
boards get no reach at all, so none of those take terms.
|
||||
- A company set to All roles (`companies.all_roles`, global) takes none on
|
||||
any of its boards, and no later role filter (category, level) either. It
|
||||
changes nothing on the narrow reach today, which takes no terms.
|
||||
- Only a reader that declares `query="one"` takes them, one series a term;
|
||||
`ask_for` has the rule for terms times the reach's series.
|
||||
- A read with terms is never the whole board: it sets no `ats:size`, and
|
||||
@@ -196,22 +198,61 @@ def fetch_terms(agents: Iterable[Agent]) -> tuple[str, ...]:
|
||||
return tuple(found[k] for k in sorted(found)) if listed else ()
|
||||
|
||||
|
||||
def wide_names(agents: Iterable[Agent], gaz: places.Gazetteer) -> str:
|
||||
"""The wide reach as the agents' `require` gates name it, for the
|
||||
Companies list: "Europe" for a gate on that place, and for a gate that
|
||||
lists countries one by one, the continent they all lie in; up to three
|
||||
names as written; "everywhere" when an agent has no such gate; "" when
|
||||
none of that fits, which `line` says as a count."""
|
||||
names: dict[str, str] = {}
|
||||
for agent in agents:
|
||||
gates = [g for g in agent.gates if g.mode == "require"
|
||||
and g.field in ("country", "place") and not gate_reach(g, gaz).everywhere]
|
||||
if not gates:
|
||||
return "everywhere"
|
||||
for gate in gates:
|
||||
values = [str(v).strip() for v in gate.values if str(v).strip()]
|
||||
if len(values) > 3:
|
||||
values = [_continent(gate_reach(gate, gaz).countries, gaz)]
|
||||
for text in values:
|
||||
names.setdefault(text.casefold(), text)
|
||||
return ", ".join(names.values()) if len(names) <= 3 and "" not in names else ""
|
||||
|
||||
|
||||
def _continent(codes: Iterable[str], gaz: places.Gazetteer) -> str:
|
||||
"""The continent every one of `codes` lies in, "" for none. A code the
|
||||
gazetteer has no country for (EU) is skipped."""
|
||||
known = {p.key for p in gaz.places.values() if p.kind == "country"}
|
||||
wanted = set(codes) & known
|
||||
for place in gaz.places.values():
|
||||
if place.kind != "continent" or not wanted:
|
||||
continue
|
||||
under = {gaz.places[p].key for p in gaz.under((place.id,))
|
||||
if gaz.places[p].kind == "country"}
|
||||
if wanted <= under:
|
||||
return place.name
|
||||
return ""
|
||||
|
||||
|
||||
@dataclass
|
||||
class Plan:
|
||||
"""The reach of one pull: `base` for every board, `wide` for the boards
|
||||
of the companies in `tagged` (tagged All roles), each board's size by
|
||||
target, and the fetch `terms` of the wide reads."""
|
||||
of the companies in `all_countries`, each board's size by target, the
|
||||
fetch `terms` of the wide reads, which skip the companies in
|
||||
`all_roles`, and `wide_names`, what the agents call the wide reach."""
|
||||
|
||||
base: Reach
|
||||
wide: Reach = EVERYWHERE
|
||||
sizes: dict[str, int] = field(default_factory=dict)
|
||||
tagged: frozenset[str] = frozenset()
|
||||
all_countries: frozenset[str] = frozenset()
|
||||
terms: tuple[str, ...] = ()
|
||||
all_roles: frozenset[str] = frozenset()
|
||||
wide_names: str = ""
|
||||
|
||||
def why(self, sub: Subscription) -> tuple[Reach, str]:
|
||||
"""The reach `sub` is read with, and why: `override`, `small`,
|
||||
`unknown` (a board never read whole), `tag` (its company is tagged
|
||||
All roles) or `agents`."""
|
||||
`unknown` (a board never read whole), `countries` (its company is
|
||||
set to All countries) or `agents`."""
|
||||
if OVERRIDE_KEYS & set(sub.params or {}):
|
||||
return EVERYWHERE, "override"
|
||||
size = self.sizes.get(sub.target)
|
||||
@@ -219,20 +260,26 @@ class Plan:
|
||||
return EVERYWHERE, "unknown"
|
||||
if size < SMALL:
|
||||
return EVERYWHERE, "small"
|
||||
if company_key(sub.company or sub.label) in self.tagged:
|
||||
return self.wide, "tag"
|
||||
if company_key(sub.company or sub.label) in self.all_countries:
|
||||
return self.wide, "countries"
|
||||
return self.base, "agents"
|
||||
|
||||
def narrows_roles(self, sub: Subscription) -> bool:
|
||||
"""Whether `sub`'s board may be narrowed by role type: its company is
|
||||
not set to All roles."""
|
||||
return company_key(sub.company or sub.label) not in self.all_roles
|
||||
|
||||
def for_subscription(self, sub: Subscription) -> dict[str, Any] | None:
|
||||
"""The `reach` a board's batch hands `ask_for`; None for none. With
|
||||
fetch terms, a tagged board's carries them and `wide`, and a board on
|
||||
the agents' reach carries them for `ask_for` to use if it drops the
|
||||
countries as too many (see the module docstring)."""
|
||||
fetch terms, and unless its company is set to All roles, a board on
|
||||
the wide reach carries them and `wide`, and a board on the agents'
|
||||
reach carries them for `ask_for` to use if it drops the countries as
|
||||
too many (see the module docstring)."""
|
||||
found, why = self.why(sub)
|
||||
out = found.params()
|
||||
if self.terms and why in ("tag", "agents") and (sub.params or {}).get("terms") is not False:
|
||||
if self.terms and why in ("countries", "agents") and self.narrows_roles(sub):
|
||||
out = (out or {}) | {"terms": list(self.terms)}
|
||||
if why == "tag":
|
||||
if why == "countries":
|
||||
out["wide"] = True
|
||||
return out
|
||||
|
||||
@@ -255,8 +302,8 @@ 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 the companies tagged
|
||||
All roles, and the sizes of `subs` (every `ats` subscription when
|
||||
"""The reach of a pull, from the enabled agents and the companies' two
|
||||
overrides, and the sizes of `subs` (every `ats` subscription when
|
||||
None)."""
|
||||
gaz = store.gazetteer()
|
||||
agents = store.agents(enabled_only=True)
|
||||
@@ -267,10 +314,14 @@ def plan(store: Store, subs: Iterable[Subscription] | None = None) -> Plan:
|
||||
if not agents:
|
||||
base = wide = EVERYWHERE
|
||||
subs = list(store.subscriptions(source="ats") if subs is None else 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, fetch_terms(agents))
|
||||
rows = store.companies()
|
||||
# All countries never reads less than the board would without it: the
|
||||
# base's remote, which a `require` of Europe does not name, is kept.
|
||||
return Plan(base, wide | base, sizes(store, subs),
|
||||
all_countries=frozenset(c.key for c in rows if c.all_countries),
|
||||
terms=fetch_terms(agents),
|
||||
all_roles=frozenset(c.key for c in rows if c.all_roles),
|
||||
wide_names=wide_names(agents, gaz) if agents else "everywhere")
|
||||
|
||||
|
||||
def reaches(store: Store, subs: Iterable[Subscription]) -> Mapping[str, dict[str, Any]]:
|
||||
@@ -282,38 +333,62 @@ 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", "tag": "company tag, too many countries to ask",
|
||||
_WHOLE = {"small": f"under {SMALL} roles", "unknown": "size not known yet",
|
||||
"override": "set here", "countries": "all countries (everywhere)",
|
||||
"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 _places(ask: readers.Ask) -> str:
|
||||
words = sorted(ask.countries) if len(ask.countries) <= 4 \
|
||||
else [f"{len(ask.countries)} countries"]
|
||||
if ask.remote:
|
||||
words.append("remote")
|
||||
return ", ".join(words)
|
||||
|
||||
|
||||
def _roles(ask: readers.Ask) -> str:
|
||||
"""The role-type half of the line: the agents' terms the board is
|
||||
asked for, or all roles."""
|
||||
if not ask.terms:
|
||||
return "all roles"
|
||||
terms = ", ".join(ask.terms) if len(ask.terms) <= 5 else f"{len(ask.terms)} terms"
|
||||
return f"follows agents' terms: {terms}"
|
||||
|
||||
|
||||
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", "33 countries, remote ·
|
||||
company tag", "57 countries · company tag · 3 terms", "all places ·
|
||||
company tag · 3 terms", "all roles · under 300 roles", "all roles ·
|
||||
Greenhouse cannot filter"."""
|
||||
reach, in plain words, countries first and role types second:
|
||||
"follows agents: DK, SE, remote · all roles", "all countries (Europe) ·
|
||||
follows agents' terms: engineer, product, data", "all countries (Europe)
|
||||
· all roles", "set here: DE · all roles", "all places, too many countries
|
||||
to ask · follows agents' terms: engineer", or, for a board read whole,
|
||||
why: "under 300 roles: read whole", "Greenhouse cannot filter: read
|
||||
whole"."""
|
||||
module = readers.HOSTS.get(sub.target.partition(":")[0])
|
||||
if module is None:
|
||||
return ""
|
||||
given, why = found.why(sub)
|
||||
ask = _runner.ask_for(module, sub.params, found.for_subscription(sub))
|
||||
terms = f" · {len(ask.terms)} term{'s' if len(ask.terms) != 1 else ''}" if ask.terms else ""
|
||||
roles = _roles(ask)
|
||||
if _runner.filtered(ask):
|
||||
words = sorted(ask.countries) if len(ask.countries) <= 4 \
|
||||
else [f"{len(ask.countries)} countries"]
|
||||
if ask.remote:
|
||||
words.append("remote")
|
||||
return f"{', '.join(words)} · {_SAID.get(why, why)}{terms}"
|
||||
if terms:
|
||||
return f"all places · {_SAID.get(why, why)}{terms}"
|
||||
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]}"
|
||||
if why == "countries":
|
||||
named = found.wide_names or f"{len(found.wide.countries)} countries"
|
||||
return f"all countries ({named}) · {roles}"
|
||||
if why == "override":
|
||||
return f"set here: {_places(ask)} · {roles}"
|
||||
return f"follows agents: {_places(ask)} · {roles}"
|
||||
if ask.terms:
|
||||
if given.everywhere:
|
||||
return f"all countries (everywhere) · {roles}"
|
||||
return f"all places, too many countries to ask · {roles}"
|
||||
if why in ("agents", "countries") and given.everywhere:
|
||||
return f"{_WHOLE[why]}: read whole"
|
||||
if why in ("agents", "countries", "override") and not module.READS.filters.declared():
|
||||
return f"{module.LABEL} cannot filter: read whole"
|
||||
reads = module.READS.filters
|
||||
if why in ("agents", "countries") and reads.country == "one" \
|
||||
and len(given.countries) > _runner.MAX_SERIES:
|
||||
return "too many countries to ask: read whole"
|
||||
if why in ("agents", "countries"):
|
||||
return f"{module.LABEL} cannot ask for these: read whole"
|
||||
return f"{_WHOLE[why]}: read whole"
|
||||
Reference in new issue
Block a user