diff --git a/app/jobs/reach.py b/app/jobs/reach.py
index ebae0b3..63f9be0 100644
--- a/app/jobs/reach.py
+++ b/app/jobs/reach.py
@@ -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"
diff --git a/app/models.py b/app/models.py
index ba2871e..cf7a7ef 100644
--- a/app/models.py
+++ b/app/models.py
@@ -1003,9 +1003,12 @@ 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.
+ #: The two fetch overrides (`app/jobs/reach.py`), global rather than an
+ #: agent's, since fetching is shared. `all_countries` 1: every big board
+ #: of the company is read with the agents' wide reach, Europe today,
+ #: rather than their places. `all_roles` 1: no role-type narrowing, no
+ #: fetch terms today, on any of its boards.
+ all_countries: int = 0
all_roles: int = 0
created_at: str
updated_at: str
diff --git a/app/static/app.css b/app/static/app.css
index 2c89fc5..8967784 100644
--- a/app/static/app.css
+++ b/app/static/app.css
@@ -1113,9 +1113,10 @@ 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"] {
+/* The two fetch overrides, All countries and All roles, global and apart
+ from the stances: green, the colour the app gives what widens (`--good`). */
+.affinity button[data-value="countries"][aria-pressed="true"],
+.affinity button[data-value="roles"][aria-pressed="true"] {
color: var(--accent-fg); background: var(--good); border-color: var(--good);
}
@@ -1308,8 +1309,18 @@ 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. */
+/* A company row has one control more: the two fetch overrides after the stances. */
#companies-list .crow { grid-template-columns: 1fr auto auto auto; }
+.affinity button[data-value="countries"], .affinity button[data-value="roles"] {
+ white-space: nowrap;
+}
+/* At 390px their words do not fit beside the name and the stances, so they
+ take a line of their own above the board's reach, which they set. */
+@media (max-width: 640px) {
+ #companies-list .crow > .affinity[aria-label="Fetch overrides"] {
+ grid-column: 1 / -1; justify-self: start;
+ }
+}
/* 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) {
diff --git a/app/static/app.js b/app/static/app.js
index 908a1f2..4f31f50 100644
--- a/app/static/app.js
+++ b/app/static/app.js
@@ -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`) and the All roles tag beside it (`allRolesControl`). One
+ * `setAffinity`) and the two fetch overrides beside it, All countries and
+ * All roles (`overridesControl`). One
* copy each, since two copies of a helper is one of them
* being fixed.
*
@@ -184,55 +185,85 @@
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) {
+ /* The two fetch overrides, one more pair of toggles in the affinity
+ buttons' fragment beside them, in a group of their own since they are
+ global rather than an agent's stance (app/jobs/reach.py). Fetching has
+ two filters, and by default a company follows the agents on both:
+ - All countries reads its big boards (300 roles or more) with the
+ agents' wide reach, Europe today, rather than their places.
+ - All roles reads them with no role-type narrowing: none of the agents'
+ fetch terms, which only apply with the wide reach, and none of the
+ role filters that may come later.
+ 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 filters again. `company` is the shared list's row;
+ `onChange` runs after the server accepted a switch, with the company it
+ answered. */
+ const OVERRIDES = [
+ { value: "countries", field: "all_countries", path: "all-countries", text: "All countries",
+ on: "All countries is on: this company's big boards are read across the agents' wide "
+ + "reach (Europe), not only the agents' places. The default is the agents' places. "
+ + "Boards under 300 roles are read whole either way. Turning it off asks nothing "
+ + "first: no role closes until the next pull reads the board again.",
+ off: "All countries: read this company's big boards across the agents' wide reach "
+ + "(Europe) instead of the agents' places, the default. Boards under 300 roles are "
+ + "read whole already. Turning it on queues a pull.",
+ said: (on) => (on ? "all countries in the agents' wide reach" : "the agents' places") },
+ { value: "roles", field: "all_roles", path: "all-roles", text: "All roles",
+ on: "All roles is on: this company's boards are read with no role-type narrowing, "
+ + "none of the agents' fetch terms. The default follows the terms, which only apply "
+ + "with All countries or on a host that cannot ask for each country. Turning it off "
+ + "asks nothing first.",
+ off: "All roles: no role-type narrowing for this company, none of the agents' fetch "
+ + "terms, the default, nor later role filters. The terms only apply with All "
+ + "countries or on a host that cannot ask for each country, so on its own this "
+ + "changes nothing today. Turning it on queues a pull.",
+ said: (on) => (on ? "every role type" : "the agents' terms") },
+ ];
+
+ function overridesControl(companyKey, company, 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);
+ span.setAttribute("aria-label", "Fetch overrides");
+ for (const o of OVERRIDES) {
+ const current = Boolean(company && company[o.field]);
+ const button = document.createElement("button");
+ button.type = "button";
+ button.dataset.value = o.value;
+ button.textContent = o.text;
+ button.title = current ? o.on : o.off;
+ button.setAttribute("aria-label", o.text);
+ button.setAttribute("aria-pressed", String(current));
+ button.addEventListener("click", () => setOverride(companyKey, o, !current, onChange));
+ span.appendChild(button);
+ }
return span;
}
- async function setAllRoles(companyKey, on, onChange) {
+ async function setOverride(companyKey, o, on, onChange) {
if (!companyKey) return;
let updated;
try {
- updated = await api(`/api/companies/${encodeURIComponent(companyKey)}/all-roles`, {
+ updated = await api(`/api/companies/${encodeURIComponent(companyKey)}/${o.path}`, {
method: "POST", body: { on },
});
} catch (err) {
return;
}
const company = companies.get(companyKey);
- if (company) company.all_roles = Boolean(updated.all_roles);
+ if (company) {
+ company.all_countries = Boolean(updated.all_countries);
+ 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.`);
+ ? `${updated.name}: ${o.said(true)}. Reading now, or with the pull right after.`
+ : `${updated.name}: back to ${o.said(false)} from the next pull.`);
if (onChange) await onChange(updated);
}
Object.assign(window, {
api, count, cell, debounce, safeUrl, companies, loadCompanies, affinityControl, setAffinity,
- allRolesControl,
+ overridesControl,
});
})();
diff --git a/app/static/companies.js b/app/static/companies.js
index 7d7f3f9..4fe012c 100644
--- a/app/static/companies.js
+++ b/app/static/companies.js
@@ -5,8 +5,8 @@
* 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,
- * and beside them `allRolesControl`, the All roles tag, which is global and
- * drawn with or without an agent.
+ * and beside them `overridesControl`, the two fetch overrides All countries
+ * and All roles, which are 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,18 +20,20 @@
* `/api/companies/{key}/board`, which reads the board once before keeping
* it; Detach stops reading it and keeps the company.
*
- * 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', 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.
+ * A row with a board says what a pull asks it for, countries first and role
+ * types second ("reads follows agents: DK, SE, remote · all roles", `reach`
+ * from app/jobs/reach.py), so the row shows whether the company follows the
+ * agents' filters or overrides them. Its editor has a second line that sets
+ * the board's own reach: the agents', or its own countries and remote,
+ * posted to `/api/sources/{id}/reach`. The wide reach (Europe) and no role
+ * narrowing are the company's two overrides instead, and the board's own
+ * countries win over All countries.
*/
(function () {
"use strict";
const {
- api, count, debounce, safeUrl, companies, loadCompanies, affinityControl, allRolesControl,
+ api, count, debounce, safeUrl, companies, loadCompanies, affinityControl, overridesControl,
} = window;
const $ = (sel, root = document) => root.querySelector(sel);
@@ -212,8 +214,8 @@
}
/** 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. */
+ or the board's own countries and remote. The editor points to the
+ company's two overrides, which are set beside the stars. */
function reachEditor(company, rerender) {
if (company.subscription_id == null) return null;
const own = company.reach_params || {};
@@ -244,9 +246,14 @@
shown();
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.";
+ note.textContent = [
+ company.all_countries
+ ? "All countries is on; countries set here win over it."
+ : "All countries, beside the stars, reads the agents' wide reach (Europe).",
+ company.all_roles
+ ? "All roles is on: no fetch terms."
+ : "All roles drops the agents' fetch terms.",
+ ].join(" ");
form.append(mode, codes, remote, save, note);
form.addEventListener("submit", async (event) => {
event.preventDefault();
@@ -309,6 +316,7 @@
case "favourite": return company.affinity === 2;
case "liked": return company.affinity === 1;
case "hidden": return company.affinity === -1;
+ case "all_countries": return company.all_countries === true;
case "all_roles": return company.all_roles === true;
case "on": return company.on === true;
case "off": return company.on === false;
@@ -343,7 +351,7 @@
if (agent != null) {
row.appendChild(affinityControl(company.key, company.affinity, async () => render(), agent));
}
- row.appendChild(allRolesControl(company.key, company.all_roles, async () => {
+ row.appendChild(overridesControl(company.key, company, async () => {
await loadCompanies(agentId());
render();
}));
diff --git a/app/static/roles.js b/app/static/roles.js
index 3730412..2fa4bd0 100644
--- a/app/static/roles.js
+++ b/app/static/roles.js
@@ -81,7 +81,7 @@
(function () {
"use strict";
- const { api, esc, debounce, safeUrl, companies, loadCompanies, affinityControl, allRolesControl,
+ const { api, esc, debounce, safeUrl, companies, loadCompanies, affinityControl, overridesControl,
judgeButtons, loadTracked, chipInput } = window;
const $ = (sel, root = document) => root.querySelector(sel);
@@ -1071,19 +1071,19 @@
el.querySelector(".strip-drop").onclick = dropCompany;
}
const slot = el.querySelector(".affinity-slot");
- const drawn = `${affinity}:${company ? company.all_roles : ""}`;
+ const drawn = `${affinity}:${company ? `${company.all_countries}:${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));
+ // The two overrides need a company row, which a first stance makes.
+ if (company) slot.append(" ", overridesControl(key, company, 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. "
- + "All fetches them from a big board."
+ + "All countries 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. All fetches them from a big board.";
+ + "agent's required gates allow. All countries fetches them from a big board.";
}
const n = state.total;
el.querySelector(".strip-count").textContent = state.loaded
@@ -1362,9 +1362,9 @@
}
/* The company's ★ ▲ ⊘, the one place a company is judged outside the
- 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
+ Companies page, and its two fetch overrides 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 overrides, which need a row, wait for it. A
change dims or undims its rows in the feed. */
function renderAffinity(slot, r) {
const company = companies.get(r.company_key);
@@ -1375,7 +1375,7 @@
renderFeed();
}, state.filter.agent));
if (company) {
- slot.append(" ", allRolesControl(r.company_key, company.all_roles,
+ slot.append(" ", overridesControl(r.company_key, company,
async () => renderAffinity(slot, r)));
}
}
diff --git a/app/storage/schema.py b/app/storage/schema.py
index 8622f75..dc2f2f7 100644
--- a/app/storage/schema.py
+++ b/app/storage/schema.py
@@ -195,9 +195,11 @@ 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. 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.
+-- '' when nobody has to. The two fetch overrides, global since fetching is
+-- shared (app/jobs/reach.py): all_countries 1 reads every big board of the
+-- company with the agents' wide reach, Europe today, rather than their
+-- places; all_roles 1 reads them with no role-type narrowing, no fetch terms
+-- today. Until migration 24, all_roles meant what all_countries means now.
CREATE TABLE IF NOT EXISTS companies (
key TEXT PRIMARY KEY,
name TEXT NOT NULL,
@@ -222,7 +224,8 @@ CREATE TABLE IF NOT EXISTS companies (
last_funding_currency TEXT NOT NULL DEFAULT '',
facts_source TEXT NOT NULL DEFAULT '',
facts_at TEXT NOT NULL DEFAULT '',
- all_roles INTEGER NOT NULL DEFAULT 0
+ all_roles INTEGER NOT NULL DEFAULT 0,
+ all_countries INTEGER NOT NULL DEFAULT 0
);
-- Every folded spelling of a company (models.company_fold): orsted is Ørsted
@@ -604,6 +607,10 @@ ALTER TABLE companies ADD COLUMN hand_reason TEXT NOT NULL DEFAULT '';
# A Python step: it adds the column only where it is missing.
(23, "agents.fetch_terms: words that narrow what big boards read with the wide reach "
"send", lambda conn: _add_fetch_terms(conn)),
+ # A Python step: params is JSON and the company is found by company_key.
+ (24, "companies.all_countries takes over the All roles tag, and companies.all_roles "
+ "means no role narrowing; a board's {\"terms\": false} becomes its company's "
+ "all_roles", lambda conn: _split_all_roles(conn)),
)
#: What a file created from `SCHEMA` today is already at.
@@ -879,6 +886,45 @@ def _add_all_roles(conn: sqlite3.Connection) -> None:
"to tag; it reads the agents' reach now", target, key)
+def _split_all_roles(conn: sqlite3.Connection) -> None:
+ """Migration 24's step. Fetching has two filters, countries and role
+ types, and each gets its own company override. `all_countries` is the
+ old All roles tag, the wide reach, copied from `all_roles` when the
+ column is added. `all_roles` keeps its column and now means no role-type
+ narrowing: a company that had the tag keeps it too, since the tag was
+ given to the favourites whose every role the owner wanted. A board whose
+ `params` hold `{"terms": false}` gives its company `all_roles`, and the
+ param goes. Runs twice without harm: the copy happens only with the new
+ column."""
+ columns = {r[1] for r in conn.execute("PRAGMA table_info(companies)")}
+ if "all_countries" not in columns:
+ conn.execute("ALTER TABLE companies ADD COLUMN all_countries INTEGER NOT NULL DEFAULT 0")
+ copied = conn.execute("UPDATE companies SET all_countries=1 WHERE all_roles=1").rowcount
+ log.info("migration 24: %d companies tagged All roles are All countries and All roles",
+ copied)
+ moved = 0
+ 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 "terms" not in params:
+ continue
+ off = params.pop("terms") is False
+ conn.execute("UPDATE subscriptions SET params=? WHERE id=?", (json.dumps(params), sub_id))
+ key = company_key(company or label)
+ if not off:
+ continue
+ if conn.execute("UPDATE companies SET all_roles=1 WHERE key=?", (key,)).rowcount:
+ moved += 1
+ else:
+ log.warning("migration 24: %s read without terms, but %r has no company row "
+ "to mark All roles; it takes the agents' terms now", target, key)
+ log.info("migration 24: %d boards' {\"terms\": false} became All roles", moved)
+
+
_V22_COLUMNS = ("seniority_host", "employment_host", "remote_host", "country_host", "employment")
_V22 = """
diff --git a/app/storage/store.py b/app/storage/store.py
index bac8d72..eec28c6 100644
--- a/app/storage/store.py
+++ b/app/storage/store.py
@@ -125,7 +125,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", "all_roles")
+ "facts_source", "facts_at", "all_roles", "all_countries")
#: 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
@@ -1938,9 +1938,16 @@ class Store:
self._alias(conn, key, fields["name"])
return self._company(key)
+ def set_all_countries(self, key: str, on: bool) -> Company:
+ """Switch a company's All countries override: its big boards are read
+ with the agents' wide reach, Europe today, rather than their places,
+ from the next pull (`app/jobs/reach.py`). Global, not per agent.
+ Raises KeyError for an unknown company."""
+ return self.update_company(key, all_countries=int(bool(on)))
+
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
+ """Switch a company's All roles override: its boards are read with no
+ role-type narrowing, no fetch terms 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)))
@@ -2001,10 +2008,11 @@ 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, 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."""
+ agent has one on `keep` already, the All countries and All roles
+ overrides carry 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:
raise ValueError("a company cannot be merged into itself")
with self.transaction() as conn:
@@ -2025,9 +2033,11 @@ 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("UPDATE companies SET "
+ "all_roles = MAX(all_roles, (SELECT all_roles FROM companies WHERE key=?)), "
+ "all_countries = MAX(all_countries, "
+ "(SELECT all_countries FROM companies WHERE key=?)) WHERE key=?",
+ (other, other, keep))
conn.execute("DELETE FROM companies WHERE key=?", (other,))
return self._company(keep)
diff --git a/app/templates/settings/agents.html b/app/templates/settings/agents.html
index df0917e..4a0f92d 100644
--- a/app/templates/settings/agents.html
+++ b/app/templates/settings/agents.html
@@ -55,7 +55,7 @@
Only roles matching
- Fetch terms narrow what a big board sends when it is read across Europe: a company tagged All roles, or a host that cannot ask for each country. The board then lists only roles whose text has one of these words, one request per word. Empty means no narrowing, and while any agent that is on has none, no board is narrowed. Boards read for Denmark or Sweden, and boards under 300 roles, are never narrowed. The words decide what is fetched, not how it ranks.
+ Fetch terms narrow what a big board sends when it is read across Europe: a company set to All countries, or a host that cannot ask for each country. A company set to All roles is never narrowed. The board then lists only roles whose text has one of these words, one request per word. Empty means no narrowing, and while any agent that is on has none, no board is narrowed. Boards read for Denmark or Sweden, and boards under 300 roles, are never narrowed. The words decide what is fetched, not how it ranks.