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]}"
+4
View File
@@ -984,6 +984,10 @@ class Company(Model):
#: Why the company is read by hand, one of `HAND_REASONS`; "" when it is
#: not on that list.
hand_reason: str = ""
#: 1 when every board of the company is read with the agents' wide reach,
#: Europe today, rather than their places (`app/jobs/reach.py`). Global,
#: not an agent's: it is about what is fetched, and fetching is shared.
all_roles: int = 0
created_at: str
updated_at: str
+7
View File
@@ -1113,6 +1113,11 @@ table.applications td[data-label="Saved"] { white-space: nowrap; color: var(--di
.affinity button[data-value="-1"][aria-pressed="true"] {
color: var(--accent-fg); background: var(--error); border-color: var(--error);
}
/* The All roles tag, global and apart from the stances: green, the colour
the app gives what widens (`--good`). */
.affinity button[data-value="all"][aria-pressed="true"] {
color: var(--accent-fg); background: var(--good); border-color: var(--good);
}
/* agents */
@@ -1302,6 +1307,8 @@ table.applications td[data-label="Saved"] { white-space: nowrap; color: var(--di
font-size: .96rem; text-decoration: none; color: inherit;
}
.crow .name { font-weight: 600; }
/* A company row has one control more: the All roles tag after the stances. */
#companies-list .crow { grid-template-columns: 1fr auto auto auto; }
/* Only a name that is a link: the Watchlist draws one without a page to
open as text, which must not look as if it led somewhere. */
@media (hover: hover) {
+50 -1
View File
@@ -16,7 +16,8 @@
* Beside `api` on `window`, the few helpers more than one page script uses:
* `count`, `cell`, `debounce`, `safeUrl`, and the company list with its
* affinity control (`loadCompanies`, `companies`, `affinityControl`,
* `setAffinity`). One copy each, since two copies of a helper is one of them
* `setAffinity`) and the All roles tag beside it (`allRolesControl`). One
* copy each, since two copies of a helper is one of them
* being fixed.
*
* Affinity is per search agent. The three company helpers take the agent's
@@ -183,7 +184,55 @@
if (onChange) await onChange(updated);
}
/* The All roles tag, one more toggle in the affinity buttons' fragment
beside them, in a group of its own since it is global rather than an
agent's stance: every board of the company is read with the agents'
wide reach, Europe today, rather than their places (app/jobs/reach.py). On queues a pull on the server, as the other
reopening switches do; off asks nothing, since no role closes until the
next pull reads the board with its filter again. `onChange` runs after
the server accepted it, with the company it answered. */
function allRolesControl(companyKey, current, onChange) {
const span = document.createElement("span");
span.className = "affinity";
span.setAttribute("role", "group");
span.setAttribute("aria-label", "Company tag");
const button = document.createElement("button");
button.type = "button";
button.dataset.value = "all";
button.textContent = "All";
button.title = current
? "All roles within the agents' wide reach (Europe), not only their places. Turning it "
+ "off asks nothing first: no role closes until the next pull reads the board again."
: "All roles: read this company's boards for all roles within the agents' wide reach "
+ "(Europe), not only their places. Turning it on queues a pull.";
button.setAttribute("aria-label", "All roles");
button.setAttribute("aria-pressed", String(Boolean(current)));
button.addEventListener("click", () => setAllRoles(companyKey, !current, onChange));
span.appendChild(button);
return span;
}
async function setAllRoles(companyKey, on, onChange) {
if (!companyKey) return;
let updated;
try {
updated = await api(`/api/companies/${encodeURIComponent(companyKey)}/all-roles`, {
method: "POST", body: { on },
});
} catch (err) {
return;
}
const company = companies.get(companyKey);
if (company) company.all_roles = Boolean(updated.all_roles);
window.toast.info(on
? `${updated.name}: all roles within the agents' wide reach. `
+ "Reading now, or with the pull right after."
: `${updated.name}: back to its reach from the next pull.`);
if (onChange) await onChange(updated);
}
Object.assign(window, {
api, count, cell, debounce, safeUrl, companies, loadCompanies, affinityControl, setAffinity,
allRolesControl,
});
})();
+26 -10
View File
@@ -4,7 +4,9 @@
* The list is app.js's shared company list (`/api/companies`), already
* joined with each company's board subscription — its id and whether it is
* on — so nothing here fetches `/api/sources` as well. The affinity buttons
* are `affinityControl`, the same ones the Roles tab and the read page draw.
* are `affinityControl`, the same ones the Roles tab and the read page draw,
* and beside them `allRolesControl`, the All roles tag, which is global and
* drawn with or without an agent.
*
* Liked and hidden are per search agent, so the `#c-agent` select above the
* list says whose the list shows and whose the buttons set. It opens on the
@@ -20,13 +22,17 @@
*
* A row with a board says what a pull asks it for ("reads DK, SE · agents",
* `reach` from app/jobs/reach.py), and its editor has a second line that
* sets the board's own reach: the agents', all roles, or its own countries
* and remote, posted to `/api/sources/{id}/reach`.
* sets the board's own reach: the agents', or its own countries and remote,
* posted to `/api/sources/{id}/reach`. All roles within the agents' wide
* reach (Europe) is the company's All roles tag instead, which the board's
* own countries win over.
*/
(function () {
"use strict";
const { api, count, debounce, safeUrl, companies, loadCompanies, affinityControl } = window;
const {
api, count, debounce, safeUrl, companies, loadCompanies, affinityControl, allRolesControl,
} = window;
const $ = (sel, root = document) => root.querySelector(sel);
/** @type {object[]} the search agents, by id */
@@ -205,8 +211,9 @@
return form;
}
/** The open row's reach editor, for a row with a board: the agents' reach,
all roles, or the board's own countries and remote. */
/** The open row's reach editor, for a row with a board: the agents' reach
or the board's own countries and remote. The wide reach is the
company's All roles tag, which the editor points to. */
function reachEditor(company, rerender) {
if (company.subscription_id == null) return null;
const own = company.reach_params || {};
@@ -215,11 +222,10 @@
form.autocomplete = "off";
const mode = document.createElement("select");
mode.setAttribute("aria-label", `What ${company.name}'s board is asked for`);
for (const [value, label] of [["agents", "Agents' reach"], ["all", "All roles"],
["own", "These countries"]]) {
for (const [value, label] of [["agents", "Agents' reach"], ["own", "These countries"]]) {
mode.appendChild(new Option(label, value));
}
mode.value = own.reach === "all" ? "all" : (own.countries || own.remote != null ? "own" : "agents");
mode.value = own.countries || own.remote != null ? "own" : "agents";
const codes = document.createElement("input");
codes.type = "text";
codes.spellcheck = false;
@@ -236,7 +242,12 @@
const shown = () => { codes.hidden = remote.hidden = mode.value !== "own"; };
mode.addEventListener("change", shown);
shown();
form.append(mode, codes, remote, save);
const note = document.createElement("span");
note.className = "muted small";
note.textContent = company.all_roles
? "The All roles tag is on; a reach set here wins over it."
: "All roles within the agents' wide reach (Europe): the All tag beside the stars.";
form.append(mode, codes, remote, save, note);
form.addEventListener("submit", async (event) => {
event.preventDefault();
save.disabled = true;
@@ -298,6 +309,7 @@
case "favourite": return company.affinity === 2;
case "liked": return company.affinity === 1;
case "hidden": return company.affinity === -1;
case "all_roles": return company.all_roles === true;
case "on": return company.on === true;
case "off": return company.on === false;
case "unreadable": return company.subscription_id == null && !company.from_search;
@@ -331,6 +343,10 @@
if (agent != null) {
row.appendChild(affinityControl(company.key, company.affinity, async () => render(), agent));
}
row.appendChild(allRolesControl(company.key, company.all_roles, async () => {
await loadCompanies(agentId());
render();
}));
row.appendChild(subLine(company, render));
if (editing === company.key) {
row.appendChild(boardEditor(company, render));
+18 -9
View File
@@ -81,8 +81,8 @@
(function () {
"use strict";
const { api, esc, debounce, safeUrl, companies, loadCompanies, affinityControl, judgeButtons,
loadTracked, chipInput } = window;
const { api, esc, debounce, safeUrl, companies, loadCompanies, affinityControl, allRolesControl,
judgeButtons, loadTracked, chipInput } = window;
const $ = (sel, root = document) => root.querySelector(sel);
// Below this the rail is over the feed rather than beside it, and the reader
@@ -1071,15 +1071,19 @@
el.querySelector(".strip-drop").onclick = dropCompany;
}
const slot = el.querySelector(".affinity-slot");
if (slot.dataset.affinity !== String(affinity)) {
slot.dataset.affinity = String(affinity);
const drawn = `${affinity}:${company ? company.all_roles : ""}`;
if (slot.dataset.affinity !== drawn) {
slot.dataset.affinity = drawn;
slot.replaceChildren(affinityControl(key, affinity,
(updated) => affinityChanged(key, company, updated), state.filter.agent));
// The All roles tag needs a company row, which a first stance makes.
if (company) slot.append(" ", allRolesControl(key, company.all_roles, renderStrip));
// What ★ does, before; what it did, after.
el.querySelector(".strip-note").textContent = affinity === 2
? "★ Favourite: roles from every place the agent's required gates allow are listed."
? "★ Favourite: roles from every place the agent's required gates allow are listed. "
+ "All fetches them from a big board."
: "★ Favourite also lists this company's roles outside your places, as far as the "
+ "agent's required gates allow.";
+ "agent's required gates allow. All fetches them from a big board.";
}
const n = state.total;
el.querySelector(".strip-count").textContent = state.loaded
@@ -1358,9 +1362,10 @@
}
/* The company's ★ ▲ ⊘, the one place a company is judged outside the
Companies page. A company seen only through a search has no row until
its first change creates one, so the list is reloaded then. A change
dims or undims its rows in the feed. */
Companies page, and its All roles tag beside them. A company seen only
through a search has no row until its first change creates one, so the
list is reloaded then, and the tag, which needs a row, waits for it. A
change dims or undims its rows in the feed. */
function renderAffinity(slot, r) {
const company = companies.get(r.company_key);
if (!r.company_key) { slot.replaceChildren(); return; }
@@ -1369,6 +1374,10 @@
renderAffinity(slot, r);
renderFeed();
}, state.filter.agent));
if (company) {
slot.append(" ", allRolesControl(r.company_key, company.all_roles,
async () => renderAffinity(slot, r)));
}
}
/* The answer, into the role on screen and into its row, whose excerpt is
+45 -3
View File
@@ -18,7 +18,7 @@ import sqlite3
from collections.abc import Callable
from app import places
from app.models import SENIORITIES, company_fold, country_of, posted_at, posted_host
from app.models import SENIORITIES, company_fold, company_key, country_of, posted_at, posted_host
from app.seniority import from_title
from app.storage import gazetteer
@@ -182,7 +182,9 @@ CREATE TABLE IF NOT EXISTS role_tags (
-- worth checking by hand, 0 not; careers_opened_at when its careers page was
-- last opened from there, which is also when a person last looked at it.
-- hand_reason is why a person reads the careers page (models.HAND_REASONS),
-- '' when nobody has to.
-- '' when nobody has to. all_roles 1 reads every board of the company with
-- the agents' wide reach, Europe today (app/jobs/reach.py); global, since
-- fetching is shared.
CREATE TABLE IF NOT EXISTS companies (
key TEXT PRIMARY KEY,
name TEXT NOT NULL,
@@ -206,7 +208,8 @@ CREATE TABLE IF NOT EXISTS companies (
last_funding INTEGER,
last_funding_currency TEXT NOT NULL DEFAULT '',
facts_source TEXT NOT NULL DEFAULT '',
facts_at TEXT NOT NULL DEFAULT ''
facts_at TEXT NOT NULL DEFAULT '',
all_roles INTEGER NOT NULL DEFAULT 0
);
-- Every folded spelling of a company (models.company_fold): orsted is Ørsted
@@ -559,6 +562,11 @@ ALTER TABLE companies ADD COLUMN hand_reason TEXT NOT NULL DEFAULT '';
# A Python step: the seed folds every name.
(20, "company_aliases and the empty enrichment columns of companies",
lambda conn: _add_company_aliases(conn)),
# A Python step: params is JSON, the company is found by company_key and
# each board that read everywhere is logged.
(21, "companies.all_roles: a company tag that reads its boards with the agents' wide "
"reach, given to every favourite and taking over a board's {\"reach\": \"all\"}",
lambda conn: _add_all_roles(conn)),
)
#: What a file created from `SCHEMA` today is already at.
@@ -791,6 +799,40 @@ def _add_company_aliases(conn: sqlite3.Connection) -> None:
log.info("migration 20: %d companies folded, %d folds shared", len(rows), len(clashes))
def _add_all_roles(conn: sqlite3.Connection) -> None:
"""Migration 21's step. The column; the tag for every company that is a
favourite of any agent, since favourite no longer widens what a pull
fetches and the tag does, so nothing read today is lost; and the tag for
each company whose board's `params` held `{"reach": "all"}`, which the
step removes from them. Such a board read everywhere and reads the wide
reach from now on, so each is logged. Runs twice without harm."""
columns = {r[1] for r in conn.execute("PRAGMA table_info(companies)")}
if "all_roles" not in columns:
conn.execute("ALTER TABLE companies ADD COLUMN all_roles INTEGER NOT NULL DEFAULT 0")
starred = conn.execute(
"UPDATE companies SET all_roles=1 WHERE all_roles=0 AND key IN "
"(SELECT company_key FROM agent_companies WHERE affinity=2)").rowcount
log.info("migration 21: %d favourite companies tagged All roles", starred)
for sub_id, target, company, label, raw in conn.execute(
"SELECT id, target, company, label, params FROM subscriptions "
"WHERE source = 'ats'").fetchall():
try:
params = json.loads(raw or "{}")
except ValueError:
continue
if not isinstance(params, dict) or params.get("reach") != "all":
continue
del params["reach"]
conn.execute("UPDATE subscriptions SET params=? WHERE id=?", (json.dumps(params), sub_id))
key = company_key(company or label)
if conn.execute("UPDATE companies SET all_roles=1 WHERE key=?", (key,)).rowcount:
log.warning("migration 21: %s read all roles everywhere; %r is tagged All roles, "
"which reads the agents' wide reach", target, key)
else:
log.warning("migration 21: %s read all roles everywhere, but %r has no company row "
"to tag; it reads the agents' reach now", target, key)
def user_version(conn: sqlite3.Connection) -> int:
return int(conn.execute("PRAGMA user_version").fetchone()[0])
+13 -3
View File
@@ -116,7 +116,7 @@ _EXCERPT_RAW = 240
_COMPANY_FIELDS = ("name", "domain", "status", "careers_url", "notes", "ats", "country", "city",
"ats_slug", "watch", "careers_opened_at", "hand_reason", "sector", "stage",
"size_band", "founded", "last_funding", "last_funding_currency",
"facts_source", "facts_at")
"facts_source", "facts_at", "all_roles")
#: A company as the store serves it: the row and the asked-for agent's affinity.
_COMPANY_SELECT = """SELECT c.*, COALESCE(ac.affinity, 0) AS affinity FROM companies c
@@ -1835,6 +1835,13 @@ class Store:
self._alias(conn, key, fields["name"])
return self._company(key)
def set_all_roles(self, key: str, on: bool) -> Company:
"""Tag a company All roles, or untag it: its boards are read with the
agents' wide reach, Europe today, from the next pull
(`app/jobs/reach.py`). Global, not per agent. Raises KeyError for an
unknown company."""
return self.update_company(key, all_roles=int(bool(on)))
def remove_company(self, key: str) -> bool:
"""Delete the row and every agent's stance on it, in one transaction:
`agent_companies` holds the key with no foreign key to hold it back, so
@@ -1891,8 +1898,8 @@ class Store:
def merge_companies(self, keep: str, other: str) -> Company:
"""Fold company `other` into `keep`, in one transaction: its roles and
subscriptions move to `keep`, each agent's stance moves unless the
agent has one on `keep` already, its aliases and its name become
aliases of `keep`, and its row goes. Copies are not recomputed
agent has one on `keep` already, an All roles tag carries over, its
aliases and its name become aliases of `keep`, and its row goes. Copies are not recomputed
(`rebuild_dupes`). Raises KeyError for an unknown company and
ValueError for merging one into itself."""
if keep == other:
@@ -1915,6 +1922,9 @@ class Store:
(keep, other))
conn.execute("DELETE FROM company_aliases WHERE company_key=?", (other,))
self._alias(conn, keep, rows[other])
conn.execute("UPDATE companies SET all_roles = MAX(all_roles, "
"(SELECT all_roles FROM companies WHERE key=?)) WHERE key=?",
(other, keep))
conn.execute("DELETE FROM companies WHERE key=?", (other,))
return self._company(keep)
+1
View File
@@ -106,6 +106,7 @@
<option value="favourite">Favourite</option>
<option value="liked">Liked</option>
<option value="hidden">Hidden</option>
<option value="all_roles">All roles</option>
<option value="on">On</option>
<option value="off">Off</option>
<option value="unreadable">Not readable yet</option>
+33 -9
View File
@@ -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),
+2 -2
View File
@@ -76,7 +76,7 @@ What was decided for roledesk and the one reason for each. The longer reasoning
**Switching a board or search off closes its open roles.** Only a pull that reads a target closes its roles, so a target no longer read would keep them open for good. Switched back on, the next pull reopens what it still lists. A batch already in flight when the switch happens reopens them again, so the pull's settle closes every switched-off target once more.
**A destructive switch asks first; a reopening one queues a pull instead of waiting for the schedule.** Switching a company's board or a job board search off, replacing a company's board (the Follow form and the row's Set board/Change editor, both `set_board`) and detaching one each close open roles in a tap; the page asks first when there are roles to lose, naming the count, a replace also naming the old and the new board, the same as removing a search and deleting an agent already do. Switching a target back on, following a board, setting a board and saving a search used to answer with nothing until the schedule's next pull, up to six hours later; each now queues `pull` right after, in the API route (`/api/sources/{id}/switch`, `/api/companies/{key}/board`, `/api/boards`, `/api/searches`) rather than in the page's script, so a script or `app job pull` calling the same endpoint gets what a click gets. `pull`'s own refusal while one is already running (`claim_run`) is not surfaced as an error: the change is read by the run already in flight, or by the very next one either way.
**A destructive switch asks first; a reopening one queues a pull instead of waiting for the schedule.** Switching a company's board or a job board search off, replacing a company's board (the Follow form and the row's Set board/Change editor, both `set_board`) and detaching one each close open roles in a tap; the page asks first when there are roles to lose, naming the count, a replace also naming the old and the new board, the same as removing a search and deleting an agent already do. Switching a target back on, following a board, setting a board, tagging a company All roles and saving a search used to answer with nothing until the schedule's next pull, up to six hours later; each now queues `pull` right after, in the API route (`/api/sources/{id}/switch`, `/api/companies/{key}/board`, `/api/companies/{key}/all-roles`, `/api/boards`, `/api/searches`) rather than in the page's script, so a script or `app job pull` calling the same endpoint gets what a click gets. `pull`'s own refusal while one is already running (`claim_run`) is not surfaced as an error: the change is read by the run already in flight, or by the very next one either way.
**The Sources tab and the CLI share `app.jobs.sources`.** Adding a board or a search and switching one are one function each, called by `app companies`, `app searches` and `/api/sources*`, so the two cannot disagree about what "off" does. A search or board is run once before it is saved, and refused if it does not answer. A search that finds nothing is refused too, since that is usually a typo in the query; a board that lists nothing is kept, since a company between openings is still one to follow.
@@ -112,7 +112,7 @@ What was decided for roledesk and the one reason for each. The longer reasoning
**One runner calls every reader.** `plugins/readers/_runner.py` owns the guarded fetch, paging, one request series per filter value unioned by id, completeness, the fallback feed, 429s and failures. `plugins/ats.py` and `plugins/search.py` are thin `Source` classes over it and keep their state prefixes, so no stored key moved. A paged read cut by `MAX_PAGES` saves its cursor and continues on the next pull; the sweep that reaches the end closes what it did not list. A host ceiling (Workday 2,000) is not swept; a filter has to get under it.
**The agents set the reach of a pull.** `app/jobs/reach.py` computes it once per pull: the union of the enabled agents' `any` gates on country, town (as its country) and remote, or everything when one agent has none. A favourite company is read with its agent's `require` reach, Europe today, so a company worth asking is read beyond Denmark and Sweden. A board's `params` override both. Boards under 300 roles, and hosts with a one-country filter over more than 8 countries, are read whole. SmartRecruiters, Eightfold, SuccessFactors, Phenom, Workday and Oracle filter at the source; countries and remote go as separate series, because the hosts intersect two facets. A complete filtered read closes roles outside the filter, except roles with a vote or an application; a filtered read, or one from a host whose unknown slug answers empty, that lists under 10% of the last read with the same filter counts as failed.
**The agents set the reach of a pull.** `app/jobs/reach.py` computes it once per pull: the union of the enabled agents' `any` gates on country, town (as its country) and remote, or everything when one agent has none. A company tagged **All roles** (`companies.all_roles`, migration 21) is read with the wide reach: the union of the enabled agents' `require` reach, Europe today, and the union of the `any` gates, so a tag never reads less than the board would untagged. An agent with no `require` gate on place makes the wide reach everywhere. For a company the owner cares about, a role in Freiburg may be open to remote, or worth asking about for Denmark, while Microsoft Germany is not wanted. The tag is separate from favourite and liked, and global rather than per agent, because it decides what is fetched and fetching is shared. Favourite (affinity 2) affects scoring only, where it skips the `any` gates; it used to widen the fetch to its agent's `require` reach, and migration 21 tagged every company that was a favourite of any agent so nothing read before is lost. The tag also replaced a board's `{"reach": "all"}` param, which read everywhere: migration 21 tagged those companies and logged each such board, since no everywhere level is left. A board's `params` override the agents' reach and the tag. Boards under 300 roles, and hosts with a one-country filter over more than 8 countries, are read whole. SmartRecruiters, Eightfold, SuccessFactors, Phenom, Workday and Oracle filter at the source; countries and remote go as separate series, because the hosts intersect two facets. A complete filtered read closes roles outside the filter, except roles with a vote or an application; a filtered read, or one from a host whose unknown slug answers empty, that lists under 10% of the last read with the same filter counts as failed.
**A role has a list of places, resolved against a gazetteer.** Readers kept one place of several, joined them, or the host posted a copy per place. A reader now returns every place and never multiplies a row. `places` (city, region, country, continent, with `place_includes` for Øresund across two countries) and `place_aliases` are seeded from the dictionaries that were in code; `role_places` links each place of a role, and an unknown text is listed by `unresolved_places` until an alias links it. The Place filter and the gates join over the tree, which halved their time and dropped the `EU` fallback. Copies of one posting per place, same host, company and title and texts at least 30% alike, fold into one role that keeps each copy's place and link; the rule applies to every host, since the 5,024 such roles came mostly from hosts that do not declare copies.
+3 -4
View File
@@ -19,10 +19,9 @@ its slug is. Every board is read independently; one that fails is logged,
recorded as failing under `ats:failing:<target>`, and skipped. A board's
filter is the `reach` option the pull hands it (the agents', see
`app/jobs/reach.py`), over which its subscription `params` (`{"countries":
["DK"], "remote": true}`, `{"reach": "all"}`) win, narrowed to what its
reader declares (`_runner.ask_for`). An unfiltered read records the board's
size under `ats:size:<target>`, which the reach reads to leave small boards
whole.
["DK"], "remote": true}`) win, narrowed to what its reader declares
(`_runner.ask_for`). An unfiltered read records the board's size under
`ats:size:<target>`, which the reach reads to leave small boards whole.
A pull reads listings only. A host that states a role's text on the role's
own page (`text="detail"`) is read there by `app/jobs/enrich.py` after
+5 -6
View File
@@ -290,7 +290,7 @@ def resolve_key(key: Key, keys: Mapping[str, Any] | None) -> dict[str, str]:
#: The most series a reach may cost on a `one` filter: a reach of more
#: countries (a favourite's Europe) reads such a host unfiltered instead.
#: countries (the wide reach, Europe) reads such a host unfiltered instead.
MAX_SERIES = 8
@@ -301,10 +301,9 @@ def ask_for(module: ModuleType, subscription_params: Mapping[str, Any] | None =
`app/jobs/reach.py`) and then the subscription's own `params` (a board's
override, e.g. `{"countries": ["DK"], "remote": true}`, or a search's
saved params) set the dimensions, params winning per dimension, narrowed
to the ones the reader declares in `READS.filters`. `{"reach": "all"}` in
the params drops the reach, and so does a reach of more than
`MAX_SERIES` countries on a reader whose country filter is `one`. A
`remote` of False asks nothing. A search's params go whole into
to the ones the reader declares in `READS.filters`. A reach of more
than `MAX_SERIES` countries on a reader whose country filter is `one` is
dropped. A `remote` of False asks nothing. A search's params go whole into
`Ask.params`; a reader with `READS.key` gets the resolved key under
`Ask.params["key"]` (see `resolve_key`, which raises when it is missing).
A module without `READS` gets `Ask()`."""
@@ -312,7 +311,7 @@ def ask_for(module: ModuleType, subscription_params: Mapping[str, Any] | None =
return Ask()
reads: Reads = module.READS
params = dict(subscription_params or {})
reached = {} if params.get("reach") == "all" else _dimensions(module, reach or {})
reached = _dimensions(module, reach or {})
if reads.filters.country == "one" and len(reached.get("country", ())) > MAX_SERIES:
reached = {}
wanted = reached | _dimensions(module, params)
+40 -1
View File
@@ -147,7 +147,7 @@ def test_migration_20_seeds_an_old_file_and_leaves_collisions(tmp_path: Path) ->
"VALUES (?, ?, '', '')", (key, name))
conn.execute("PRAGMA user_version = 19")
reopened = Store(path)
assert reopened.migrations_applied == [20]
assert reopened.migrations_applied == [20, 21]
assert reopened.duplicate_companies() == [("orsted", ["orsted", "ørsted"])]
assert len(reopened.companies()) == 3
@@ -158,3 +158,42 @@ def test_the_step_runs_twice_without_harm(tmp_path: Path) -> None:
with sqlite3.connect(path) as conn:
undo_v20(conn)
_add_company_aliases(conn)
def test_migration_21_tags_the_favourites_and_the_boards_that_read_all_roles(tmp_path: Path) -> None:
path = tmp_path / "old.db"
store = Store(path)
store.add_company("Mistral AI")
store.add_company("Acme")
store.add_subscription("ats", "smartrecruiters:mistral", label="Mistral AI",
company="Mistral AI", board="smartrecruiters",
params={"reach": "all", "note": "kept"})
store.add_subscription("ats", "workday:acme", label="Acme", company="Acme",
board="workday", params={"countries": ["DK"]})
# A board whose company has no row: its params are cleaned, no flag lands.
store.add_subscription("ats", "greenhouse:ghost", label="Ghost", company="Ghost",
board="greenhouse", params={"reach": "all"})
# A favourite of any agent, enabled or not, is tagged: favourite no
# longer widens the fetch, the tag does.
store.add_company("Black Forest Labs")
store.add_company("Liked")
off = store.save_agent("Off", enabled=False)
store.set_affinity(off.id, "black-forest-labs", 2) # type: ignore[arg-type]
store.set_affinity(off.id, "liked", 1) # type: ignore[arg-type]
with sqlite3.connect(path) as conn:
conn.execute("ALTER TABLE companies DROP COLUMN all_roles")
conn.execute("PRAGMA user_version = 20")
reopened = Store(path)
assert reopened.migrations_applied == [21]
assert {c.key: c.all_roles for c in reopened.companies()} == {
"mistral-ai": 1, "acme": 0, "black-forest-labs": 1, "liked": 0}
params = {s.target: s.params for s in reopened.subscriptions(source="ats")}
assert params == {"smartrecruiters:mistral": {"note": "kept"},
"workday:acme": {"countries": ["DK"]}, "greenhouse:ghost": {}}
def test_a_merge_keeps_the_all_roles_tag(store: Store) -> None:
store.add_company("Mistral")
store.add_company("Mistral AI")
store.set_all_roles("mistral", True)
assert store.merge_companies("mistral-ai", "mistral").all_roles == 1
+1 -1
View File
@@ -246,7 +246,7 @@ def test_a_v17_file_gains_dup_of_with_its_first_rebuild(tmp_path: Path) -> None:
migrated = Store(path)
assert migrated.migrations_applied == [18, 19, 20]
assert migrated.migrations_applied == [18, 19, 20, 21]
assert dup_of(migrated) == {first.uid: None, second.uid: first.uid}
with sqlite3.connect(path) as conn:
assert conn.execute("SELECT 1 FROM sqlite_master WHERE name = 'idx_roles_dup_of'"
+81 -14
View File
@@ -1,5 +1,5 @@
"""The reach of a pull (`app.jobs.reach`): from the enabled agents' gates and
favourites to each board's `reach`, and through the pull's batches to the
All roles tags to each board's `reach`, and through the pull's batches to the
runner's `Ask`. No network: the runner's listing is stubbed."""
from __future__ import annotations
@@ -107,31 +107,72 @@ def test_the_require_reach_intersects_and_expands_europe(store: Store) -> None:
# ------------------------------------------------------------- per board
def test_a_favourite_is_read_across_the_require_reach(store: Store) -> None:
def test_a_company_tagged_all_roles_is_read_across_the_require_reach(store: Store) -> None:
_wolf(store)
_board(store, "workday:mistral.wd3/Jobs", "Mistral AI")
_board(store, "workday:acme.wd3/Jobs", "Acme")
store.set_all_roles("mistral-ai", True)
plan = reach.plan(store)
subs = {s.target.split(".")[0]: s for s in store.subscriptions(source="ats")}
wide, why = plan.why(subs["workday:mistral"])
# Europe, and the base's remote, which a tag never reads less than.
assert why == "tag" and {"DE", "FR", "DK"} <= wide.countries and wide.remote
assert reach.line(plan, subs["workday:mistral"]) == \
f"{len(wide.countries)} countries, remote · company tag"
assert plan.why(subs["workday:acme"]) == (plan.base, "agents")
def test_a_favourite_does_not_widen_the_fetch(store: Store) -> None:
wolf = _wolf(store)
_board(store, "smartrecruiters:mistral", "Mistral AI")
_board(store, "smartrecruiters:acme", "Acme")
store.set_affinity(wolf, "mistral-ai", 2)
plan = reach.plan(store)
subs = {s.target: s for s in store.subscriptions(source="ats")}
favourite, why = plan.why(subs["smartrecruiters:mistral"])
assert why == "favourite" and {"DE", "FR", "DK"} <= favourite.countries
assert plan.why(subs["smartrecruiters:acme"]) == (plan.base, "agents")
[sub] = store.subscriptions(source="ats")
assert plan.why(sub) == (plan.base, "agents")
def test_a_company_starred_by_one_agent_keeps_the_others_reach(store: Store) -> None:
wolf = _wolf(store)
@pytest.mark.parametrize("host", ["smartrecruiters", "successfactors", "eightfold"])
def test_a_tag_too_wide_for_a_one_host_reads_the_board_whole(store: Store, host: str) -> None:
_wolf(store)
_board(store, f"{host}:mistral", "Mistral AI")
store.set_all_roles("mistral-ai", True)
[sub] = store.subscriptions(source="ats")
assert reach.line(reach.plan(store), sub) == \
"all roles · company tag, too many countries to ask"
def test_a_tag_asks_phenom_for_europe_in_one_request(store: Store) -> None:
_wolf(store)
_board(store, "phenom:mistral", "Mistral AI")
store.set_all_roles("mistral-ai", True)
[sub] = store.subscriptions(source="ats")
found = reach.plan(store)
assert reach.line(found, sub) == f"{len(found.wide.countries)} countries · company tag"
def test_an_agent_without_a_required_place_makes_the_tag_everywhere(store: Store) -> None:
_wolf(store)
store.save_agent("Anywhere", gates=[Gate(field="country", values=["US"], mode="any")])
_board(store, "smartrecruiters:mistral", "Mistral AI")
store.set_affinity(wolf, "mistral-ai", 2)
favourite = reach.plan(store).favourites["mistral-ai"]
assert "US" in favourite.countries and "FR" in favourite.countries
_board(store, "workday:mistral.wd3/Jobs", "Mistral AI")
store.set_all_roles("mistral-ai", True)
plan = reach.plan(store)
[sub] = store.subscriptions(source="ats")
assert plan.why(sub) == (reach.EVERYWHERE, "tag")
assert plan.for_subscription(sub) is None
assert reach.line(plan, sub) == "all roles · company tag"
def test_a_boards_own_reach_wins_over_the_tag(store: Store) -> None:
_wolf(store)
_board(store, "workday:mistral.wd3/Jobs", "Mistral AI", params={"countries": ["FR"]})
store.set_all_roles("mistral-ai", True)
[sub] = store.subscriptions(source="ats")
assert reach.line(reach.plan(store), sub) == "FR · set here"
@pytest.mark.parametrize("size, params, why", [
(299, {}, "small"),
(None, {}, "unknown"),
(5000, {"reach": "all"}, "override"),
(5000, {"countries": ["DE"]}, "override"),
(300, {}, "agents"),
])
@@ -202,6 +243,32 @@ def test_the_pull_hands_each_board_its_reach_and_the_runner_narrows_it(
assert store.state["ats:size:smartrecruiters:BoschGroup"] == "1000"
def test_the_pull_reads_a_tagged_company_with_the_wide_reach(
store: Store, monkeypatch: pytest.MonkeyPatch) -> None:
_wolf(store)
_board(store, "phenom:jobs.mistral.ai/global/en", "Mistral AI")
_board(store, "smartrecruiters:bfl", "Black Forest Labs")
store.set_all_roles("mistral-ai", True)
store.set_all_roles("black-forest-labs", True)
asked: dict[str, Ask] = {}
def fake(module: object, slug: str, get: object, ask: Ask, **kwargs: object
) -> _runner.Listing:
asked[slug] = ask
return _runner.Listing([_row("1")], True, ["1"], _runner.filtered(ask)) # type: ignore[list-item]
monkeypatch.setattr(_runner, "read_listing", fake)
[batch] = _pull(store)
phenom = "phenom:jobs.mistral.ai/global/en"
assert set(batch["reach"]) == {phenom, "smartrecruiters:bfl"}
europe = set(batch["reach"][phenom]["countries"])
assert {"DE", "FR", "DK"} <= europe
assert set(asked["jobs.mistral.ai/global/en"].countries) == europe
# Europe is more series than SmartRecruiters is asked one by one: whole.
assert asked["bfl"] == Ask()
assert not store.state.get("ats:filtered:smartrecruiters:bfl")
def test_a_batch_queued_before_the_reach_existed_still_runs(
store: Store, monkeypatch: pytest.MonkeyPatch) -> None:
_board(store, "smartrecruiters:acme", "Acme")
-1
View File
@@ -242,7 +242,6 @@ def test_a_reach_too_wide_for_a_one_host_reads_it_unfiltered() -> None:
@pytest.mark.parametrize("params, expected", [
({"reach": "all"}, Ask()),
({"countries": ["DE"], "remote": False}, Ask(countries=("DE",))),
({"remote": True}, Ask(countries=("DK",), remote=True)),
])
+6 -6
View File
@@ -69,7 +69,7 @@ def test_schema_creates_on_an_empty_file(tmp_path: Path) -> None:
"application_events", "agents", "scores", "state"} <= tables
assert "idx_roles_cluster" in indexes
assert store.migrations_applied == []
assert LATEST == 20
assert LATEST == 21
# A second open finds it current and applies nothing.
assert Store(path).migrations_applied == []
@@ -186,7 +186,7 @@ def test_a_v14_file_gains_the_watchlist_columns_and_leaves_companies_unrated(
migrated = Store(path)
assert migrated.migrations_applied == [15, 16, 17, 18, 19, 20]
assert migrated.migrations_applied == [15, 16, 17, 18, 19, 20, 21]
acme = migrated.company("acme")
assert acme is not None
assert (acme.ats, acme.careers_url) == ("teamtailor", "https://a.example")
@@ -391,7 +391,7 @@ def test_v14_makes_each_intent_the_agents_one_prompt_with_its_vector(tmp_path: P
migrated = Store(path)
assert migrated.migrations_applied == [14, 15, 16, 17, 18, 19, 20]
assert migrated.migrations_applied == [14, 15, 16, 17, 18, 19, 20, 21]
assert migrated.agent(backend.id).prompts == [ # type: ignore[union-attr]
Prompt(name="Backend", text="python backend")]
assert migrated.agent(blank.id).prompts == [] # type: ignore[union-attr]
@@ -415,7 +415,7 @@ def test_v16_gives_a_company_no_reason_and_keeps_its_row(tmp_path: Path) -> None
migrated = Store(path)
assert migrated.migrations_applied == [16, 17, 18, 19, 20]
assert migrated.migrations_applied == [16, 17, 18, 19, 20, 21]
acme = migrated.company("acme")
assert acme is not None
assert (acme.careers_url, acme.notes, acme.hand_reason) == (
@@ -444,7 +444,7 @@ def test_v17_folds_every_place_and_levels_the_titles_extract_has_not_read(
migrated = Store(path)
assert migrated.migrations_applied == [17, 18, 19, 20]
assert migrated.migrations_applied == [17, 18, 19, 20, 21]
with sqlite3.connect(path) as conn:
rows = {uid: (fold, level) for uid, fold, level in conn.execute(
"SELECT uid, place_fold, seniority FROM roles")}
@@ -686,7 +686,7 @@ def test_v19_gives_every_role_its_places_and_splits_its_level(tmp_path: Path) ->
migrated = Store(path)
assert migrated.migrations_applied == [19, 20]
assert migrated.migrations_applied == [19, 20, 21]
assert [p.name for p in migrated.role_places(joined.uid)] == ["Copenhagen", "Malmö"]
assert [p.name for p in migrated.role_places(detailed.uid)] == ["Aarhus"]
assert migrated.role_places(stated.uid) == []
+2 -2
View File
@@ -537,7 +537,7 @@ def test_companies_lists_board_and_open_role_count(
"ats": "greenhouse", "ats_slug": "", "careers_url": "",
"country": "DK", "city": "", "domain": "", "watch": None,
"careers_opened_at": "", "failing_since": "", "failing_reason": "",
"from_search": False, "hand_reason": "", "by_hand": False,
"from_search": False, "hand_reason": "", "by_hand": False, "all_roles": False,
"reach_params": {}, "reach": "all roles · not read whole yet"}
[other] = [c for c in res.json() if c["key"] == "other"]
assert (other["board"], other["subscription_id"], other["on"], other["ats"]) == (
@@ -1387,7 +1387,7 @@ def test_a_company_is_added_by_hand_with_a_reason_and_a_link(
"ats": "", "ats_slug": "", "careers_url": "https://revolut.example/careers",
"country": "", "city": "", "watch": None, "careers_opened_at": "",
"failing_since": "", "failing_reason": "", "from_search": False,
"hand_reason": "added", "by_hand": True, "reach_params": {}, "reach": ""}
"hand_reason": "added", "by_hand": True, "all_roles": False, "reach_params": {}, "reach": ""}
assert store.company("revolut").hand_reason == "added" # type: ignore[union-attr]
other = client.post("/api/companies", json={"name": "Meta", "hand_reason": "blocked"})
+35 -6
View File
@@ -67,10 +67,6 @@ def test_a_boards_own_reach_is_kept_in_its_params_and_wins(
assert sub.params == {"note": "kept", "countries": ["DE", "SE"], "remote": True}
assert _row(client)["reach_params"] == {"countries": ["DE", "SE"], "remote": True}
res = client.post(f"/api/sources/{bosch}/reach", json={"mode": "all"})
assert res.json()["reach"] == "all roles · set here"
assert store.subscription(bosch).params == {"note": "kept", "reach": "all"} # type: ignore[union-attr]
res = client.post(f"/api/sources/{bosch}/reach", json={"mode": "agents"})
assert res.json()["reach"] == "DK · agents"
assert store.subscription(bosch).params == {"note": "kept"} # type: ignore[union-attr]
@@ -81,6 +77,7 @@ def test_a_boards_own_reach_is_kept_in_its_params_and_wins(
({"mode": "own", "countries": ["XX"]}, 422),
({"mode": "own", "countries": ["EU"]}, 422),
({"mode": "nowhere"}, 422),
({"mode": "all"}, 422), # every role is the company's tag now
])
def test_a_reach_that_names_nothing_is_refused(
client: TestClient, bosch: int, body: dict[str, object], status: int) -> None:
@@ -90,8 +87,40 @@ def test_a_reach_that_names_nothing_is_refused(
def test_a_search_or_an_unknown_board_has_no_reach(client: TestClient, store: Store) -> None:
search = store.add_subscription("search", "jobindex:x", label="X", board="jobindex",
params={"q": "python"})
assert client.post(f"/api/sources/{search.id}/reach", json={"mode": "all"}).status_code == 404
assert client.post("/api/sources/999/reach", json={"mode": "all"}).status_code == 404
assert client.post(f"/api/sources/{search.id}/reach",
json={"mode": "agents"}).status_code == 404
assert client.post("/api/sources/999/reach", json={"mode": "agents"}).status_code == 404
#: Every state a job may be in, for a "was one queued at all" check that does
#: not race a background worker draining it.
_ANY_STATE = ("queued", "running", "done", "failed", "cancelled")
def test_the_all_roles_tag_reads_the_wide_reach_and_on_queues_a_pull(
client: TestClient, app: FastAPI, store: Store, bosch: int) -> None:
queue = app.state.queue
res = client.post("/api/companies/bosch/all-roles", json={"on": True})
assert res.status_code == 200, res.text
assert res.json()["all_roles"] == 1
# On reopens roles, so it queues a pull as switching a board on does.
assert queue.jobs.last("pull", states=_ANY_STATE) is not None
row = _row(client)
# Wolf requires no place, so the wide reach is everywhere.
assert (row["all_roles"], row["reach"]) == (True, "all roles · company tag")
# A board's own countries win over the tag.
client.post(f"/api/sources/{bosch}/reach", json={"mode": "own", "countries": ["DE"]})
assert _row(client)["reach"] == "DE · set here"
def test_turning_the_tag_off_queues_nothing(
client: TestClient, app: FastAPI, store: Store, bosch: int) -> None:
store.set_all_roles("bosch", True)
res = client.post("/api/companies/bosch/all-roles", json={"on": False})
assert res.status_code == 200 and res.json()["all_roles"] == 0
assert app.state.queue.jobs.last("pull", states=_ANY_STATE) is None
assert _row(client)["reach"] == "DK · agents"
assert client.post("/api/companies/nobody/all-roles", json={"on": True}).status_code == 404
def test_the_readers_are_listed_with_what_they_declare(client: TestClient) -> None: