Merge branch 'main' into wp1-byhand-api

# Conflicts:
#	app/models.py
#	app/storage/schema.py
#	app/storage/store.py
#	app/web/api.py
#	tests/test_storage.py
#	tests/test_web.py
This commit is contained in:
Wolf committed 2026-09-29 19:25:42 +02:00
commit 1a2689e08d
17 files changed
+565 -109

No files matched your search

+2 -1
View File
@@ -34,12 +34,13 @@ A Jobindex query is its own syntax: words are OR, `"a b"` is a phrase, `+word` i
## The tabs ## The tabs
Two tabs, and a cog for settings. Three tabs, and a cog for settings.
| | | | | |
|---|---| |---|---|
| **Roles** | newsdesk's feed: a filter rail (Show read, Best first or Newest first, first seen, tags, more filters), the open roles with company, place, age, tags and a summary, votes (▲ like ● neither way ▼ pass) and a Save button. A title opens the reader beside the list; on a phone it takes the screen. `j`/`k` move, `Enter` opens, `/` searches | | **Roles** | newsdesk's feed: a filter rail (Show read, Best first or Newest first, first seen, tags, more filters), the open roles with company, place, age, tags and a summary, votes (▲ like ● neither way ▼ pass) and a Save button. A title opens the reader beside the list; on a phone it takes the screen. `j`/`k` move, `Enter` opens, `/` searches |
| **Applications** | the saved roles and their status, each change recorded as an event | | **Applications** | the saved roles and their status, each change recorded as an event |
| **Watchlist** | the companies whose board the app cannot read, for going through their careers pages by hand: Yes or No marks whether one is worth checking (a filter shows the unrated, the yes, the no or all), the careers page opens in a new tab and notes when, and a missing or wrong link is set in the row. A company whose board is failing is listed too. Separate from the affinity a search agent has |
The cog opens `/settings`: a rail of pages on the left, the page beside it, sticky so Runs is one click away however long the company list gets. On a phone the rail is a strip under the header. The cog opens `/settings`: a rail of pages on the left, the page beside it, sticky so Runs is one click away however long the company list gets. On a phone the rail is a strip under the header.
+5 -3
View File
@@ -934,12 +934,14 @@ class Company(Model):
#: The name `ats` knows the company by, the `acme` of acme.teamtailor.com; #: The name `ats` knows the company by, the `acme` of acme.teamtailor.com;
#: "" where discovery found none. Kept for a host no parser reads yet. #: "" where discovery found none. Kept for a host no parser reads yet.
ats_slug: str = "" ats_slug: str = ""
#: The Watchlist's rating, global and not an agent's: None not yet rated,
#: 1 worth checking by hand, 0 not.
watch: int | None = None
#: When the careers page was last opened from the Watchlist; "" never.
careers_opened_at: str = ""
#: Why the company is read by hand, one of `HAND_REASONS`; "" when it is #: Why the company is read by hand, one of `HAND_REASONS`; "" when it is
#: not on that list. #: not on that list.
hand_reason: str = "" hand_reason: str = ""
#: When a person last looked at its careers page, an ISO timestamp; ""
#: for never.
checked_at: str = ""
created_at: str created_at: str
updated_at: str updated_at: str
+11 -7
View File
@@ -198,21 +198,25 @@
} }
// The Where block in words, one sentence of the lines a role may match, // The Where block in words, one sentence of the lines a role may match,
// with the one-of rows among them since they are the same group: "Roles in // with the one-of rows among them since they are the same group: "Keeps
// Denmark, in Malmö, Lund or Helsingborg, or remote within Europe." // roles anywhere in Denmark, in Malmö, Lund or Helsingborg, or remote within
// Europe, and leaves out the rest." The lines add up, which the first
// wording ("Roles in ...") left the owner to guess.
function whereSentence(where, others) { function whereSentence(where, others) {
const parts = []; const parts = [];
if (where.countries) parts.push(phrase(where.countries)); if (where.countries) parts.push(`anywhere ${phrase(where.countries)}`);
if (where.places) parts.push(phrase(where.places)); if (where.places) parts.push(phrase(where.places));
if (where.remote) parts.push(where.europe ? "remote within Europe" : "remote"); if (where.remote) parts.push(where.europe ? "remote within Europe" : "remote");
parts.push(...others.map(phrase)); parts.push(...others.map(phrase));
if (!parts.length) return ""; if (!parts.length) return "";
return `Roles ${parts.length < 2 ? parts[0] : `${parts.slice(0, -1).join(", ")}, or ${parts[parts.length - 1]}`}.`; const list = parts.length < 2 ? parts[0] : `${parts.slice(0, -1).join(", ")}, or ${parts[parts.length - 1]}`;
return `Keeps roles ${list}, and leaves out the rest.`;
} }
// The gates in words: where a role may be, then what it must meet, then // The gates in words: where a role may be, then what it must meet, then
// what lifts it. "Roles in Denmark, or remote within Europe. Only roles // what lifts it. "Keeps roles anywhere in Denmark, or remote within Europe,
// with seniority senior. Prefers hybrid." // and leaves out the rest. Only roles with seniority senior. Prefers
// hybrid."
function rulesLine(gates) { function rulesLine(gates) {
const { where, rest } = distribute(gates); const { where, rest } = distribute(gates);
const of = (mode) => rest.filter((g) => g.mode === mode); const of = (mode) => rest.filter((g) => g.mode === mode);
@@ -604,7 +608,7 @@
const view = () => { const view = () => {
offerScope(); offerScope();
$("#a-gates", f).value = JSON.stringify(gates(), null, 2); $("#a-gates", f).value = JSON.stringify(gates(), null, 2);
$("#a-where-sum", f).textContent = rulesLine(gates()) || "Roles anywhere."; $("#a-where-sum", f).textContent = rulesLine(gates()) || "Keeps roles anywhere.";
}; };
view(); view();
+25 -6
View File
@@ -1,6 +1,6 @@
/* The whole stylesheet: the boilerplate's, with roledesk's palette in the /* The whole stylesheet: the boilerplate's, with roledesk's palette in the
* custom properties (a quiet UI face and newsdesk's teal signal colour), the * custom properties (a quiet UI face and newsdesk's teal signal colour), the
* frame (a top bar of two tabs and a cog, the settings rail), roledesk's * frame (a top bar of three tabs and a cog, the settings rail), roledesk's
* own pages, and at the bottom the phone: a width query for the layout and a * own pages, and at the bottom the phone: a width query for the layout and a
* pointer query for the sizes, after newsdesk and health. No build step. * pointer query for the sizes, after newsdesk and health. No build step.
* *
@@ -477,11 +477,11 @@ body[data-rail="shut"] #rail { display: none; }
/* Reading opens a third column and the shell goes full width: the list keeps /* Reading opens a third column and the shell goes full width: the list keeps
a narrow lane on the left, the role takes the rest. */ a narrow lane on the left, the role takes the rest. */
body[data-reader="open"] .shell { body[data-reader="open"] .shell {
grid-template-columns: 15rem 21rem minmax(0, 1fr); grid-template-columns: 15rem 29rem minmax(0, 1fr);
max-width: none; gap: 1.2rem; max-width: none; gap: 1.2rem;
} }
body[data-reader="open"][data-rail="shut"] .shell { body[data-reader="open"][data-rail="shut"] .shell {
grid-template-columns: 21rem minmax(0, 1fr); grid-template-columns: 29rem minmax(0, 1fr);
} }
/* -- the rail -- */ /* -- the rail -- */
@@ -842,12 +842,13 @@ tr.muted { opacity: .55; }
padding: 1.6rem 2rem 4rem; padding: 1.6rem 2rem 4rem;
overflow-wrap: anywhere; overflow-wrap: anywhere;
} }
/* ~68 characters a line at the reading size -- past that the eye loses the /* ~90 characters a line at the reading size: newsdesk's 36rem wrapped a
start of the next line and has to hunt for it. */ posting's short lines and lists too early. */
.reader-body > * { max-width: 36rem; margin-inline: auto; } .reader-body > * { max-width: 48rem; margin-inline: auto; }
.reader-meta { margin-top: 0; } .reader-meta { margin-top: 0; }
.reader-meta b { font-weight: 600; color: var(--dim); } .reader-meta b { font-weight: 600; color: var(--dim); }
.reader-meta .reader-careers { color: var(--dim); }
.reader-meta .affinity { font-size: .85rem; } .reader-meta .affinity { font-size: .85rem; }
.reader-meta .affinity:empty { display: none; } .reader-meta .affinity:empty { display: none; }
@@ -1339,3 +1340,21 @@ table.list select { padding: .25rem .4rem; }
.affinity button { min-width: 2.75rem; } .affinity button { min-width: 2.75rem; }
.check input { width: 1.25rem; height: 1.25rem; } .check input { width: 1.25rem; height: 1.25rem; }
} }
/* Three tabs and the cog, at 390px: the phone block's padding and size leave
the bar 37px too wide, and a nowrap bar that is too wide scrolls the whole
page sideways. Tighter tabs, still touch-high (see the coarse block). */
@media (max-width: 640px) {
.top { gap: .4rem; }
.top nav a { padding-inline: .25rem; font-size: .9rem; }
.top nav a.icon { padding-inline: .55rem; }
}
/* On Roles the search field is what gives way, not the tabs: the nav keeps
the width its tabs need and the field takes what is left. */
@media (max-width: 640px) {
.top:has(#search) nav { flex: 0 0 auto; }
.top:has(#search) nav a:not(.icon) { padding-inline: .2rem; }
/* Which leaves the field a few letters wide, so while it is typed in it
takes the bar and the tabs step aside; they are back when it is left. */
.top:has(#search:focus) nav a:not(.icon), .top:has(#search:focus) desk-queue { display: none; }
}
+3
View File
@@ -798,6 +798,7 @@
: text ? paragraphs(text) : text ? paragraphs(text)
: `<p class="reader-note">The board gave no description for this one.</p>`; : `<p class="reader-note">The board gave no description for this one.</p>`;
const pay = payDisplay(r); const pay = payDisplay(r);
const careers = safeUrl(companies.get(r.company_key)?.careers_url);
const waiting = state.summarising === state.readingUid; const waiting = state.summarising === state.readingUid;
const teaser = loaded && !r.article_text && out && (r.description || "").length < TEASER; const teaser = loaded && !r.article_text && out && (r.description || "").length < TEASER;
@@ -813,6 +814,8 @@
<div class="reader-body"> <div class="reader-body">
<div class="reader-meta"> <div class="reader-meta">
${r.company ? `<b>${esc(r.company)}</b>` : ""} ${r.company ? `<b>${esc(r.company)}</b>` : ""}
${careers ? `<a class="reader-careers" href="${esc(careers)}" target="_blank" rel="noopener"
title="The company's careers page">Careers ↗</a>` : ""}
<span class="affinity-slot"></span> <span class="affinity-slot"></span>
${r.place ? `<span>${esc(r.place)}</span>` : ""} ${r.place ? `<span>${esc(r.place)}</span>` : ""}
${r.first_seen ? `<span title="First seen">${ago(r.first_seen)}</span>` : ""} ${r.first_seen ? `<span title="First seen">${ago(r.first_seen)}</span>` : ""}
+252
View File
@@ -0,0 +1,252 @@
/* The Watchlist tab: the companies the app cannot read a board of, for
* going through their careers pages by hand.
*
* The list is app.js's shared company list (`/api/companies`), narrowed to
* the rule the "Not readable yet" filter of Company boards uses (no board
* subscription, not from a search), plus every company whose board is
* failing. The rating (`watch`: null unrated, 1 yes, 0 no) is global, not a
* search agent's affinity, and is set with `POST .../watch`. Opening the
* careers page stamps `careers_opened_at` (`POST .../opened`), so the row can
* say when, and the On the list filter sorts what was opened longest ago
* first. The filter is remembered per browser, and opens on Unrated.
*/
(function () {
"use strict";
const { api, count, debounce, safeUrl, companies, loadCompanies } = window;
const $ = (sel, root = document) => root.querySelector(sel);
const FILTER = "roledesk.watchlist";
const FILTERS = [
["unrated", "Unrated"], ["yes", "On the list"], ["no", "Not on the list"], ["all", "All"],
];
const DAY = 24 * 60 * 60 * 1000;
/** The key of the row whose careers link editor is open, or null. */
let editing = null;
function savedFilter() {
try {
const value = localStorage.getItem(FILTER);
return FILTERS.some(([f]) => f === value) ? value : "unrated";
} catch (err) {
return "unrated";
}
}
function saveFilter(value) {
try { localStorage.setItem(FILTER, value); } catch (err) { /* not remembered */ }
}
/** The companies the tab is about, before any filter. */
function watched() {
return [...companies.values()].filter(
(c) => (c.subscription_id == null && !c.from_search) || c.failing_since);
}
function matchesFilter(company, filter) {
switch (filter) {
case "unrated": return company.watch == null;
case "yes": return company.watch === 1;
case "no": return company.watch === 0;
default: return true;
}
}
function ago(iso) {
if (!iso) return "not opened yet";
const days = Math.floor((Date.now() - new Date(iso).getTime()) / DAY);
if (Number.isNaN(days)) return "not opened yet";
if (days < 1) return "opened today";
return `opened ${count(days, "day")} ago`;
}
/** Where the link goes: the careers page, else the company's own site. */
function target(company) {
const careers = safeUrl(company.careers_url);
if (careers) return { url: careers, label: "Careers page" };
const site = company.domain ? safeUrl(`https://${company.domain}`) : "";
return site ? { url: site, label: "Website" } : null;
}
async function rate(company, watch, rerender) {
try {
const updated = await api(`/api/companies/${encodeURIComponent(company.key)}/watch`, {
method: "POST", body: { watch },
});
company.watch = updated.watch;
} catch (err) {
return;
}
rerender();
}
/** Yes and No, in `.affinity`'s look; pressing the pressed one clears it. */
function ratingControl(company, rerender) {
const span = document.createElement("span");
span.className = "affinity";
span.setAttribute("role", "group");
span.setAttribute("aria-label", `Watch ${company.name}`);
for (const [value, label, watch] of [[1, "Yes", true], [-1, "No", false]]) {
const pressed = company.watch === (watch ? 1 : 0);
const button = document.createElement("button");
button.type = "button";
button.dataset.value = String(value);
button.textContent = label;
button.setAttribute("aria-pressed", String(pressed));
button.addEventListener("click", () => rate(company, pressed ? null : watch, rerender));
span.appendChild(button);
}
return span;
}
function subLine(company, rerender) {
const sub = document.createElement("span");
sub.className = "sub";
const badge = document.createElement("span");
badge.className = "badge";
badge.textContent = company.board || company.ats || "board not found";
sub.appendChild(badge);
const place = [company.city, (company.country || "").toUpperCase()].filter(Boolean).join(", ");
if (place) sub.append(` ${place}`);
if (company.failing_since) {
const failing = document.createElement("span");
failing.className = "failing";
failing.textContent = `board failing since ${company.failing_since.slice(0, 10)}`;
sub.append(" · ");
sub.appendChild(failing);
}
sub.append(" · ");
const where = target(company);
if (where) {
const link = document.createElement("a");
link.href = where.url;
link.target = "_blank";
link.rel = "noopener noreferrer";
link.textContent = where.label;
link.addEventListener("click", () => opened(company, rerender));
sub.appendChild(link);
sub.append(` · ${ago(company.careers_opened_at)} `);
}
const edit = document.createElement("button");
edit.type = "button";
edit.className = "linky";
edit.textContent = company.careers_url ? "Edit link" : "Add careers page";
edit.setAttribute("aria-expanded", String(editing === company.key));
edit.addEventListener("click", () => {
editing = editing === company.key ? null : company.key;
rerender();
});
sub.appendChild(edit);
return sub;
}
/** The link was followed: stamp it. The new tab is already open, so this
only updates the row, and only the stamp, so the row does not jump. */
async function opened(company, rerender) {
try {
const updated = await api(`/api/companies/${encodeURIComponent(company.key)}/opened`,
{ method: "POST" });
company.careers_opened_at = updated.careers_opened_at;
} catch (err) {
return;
}
rerender();
}
function linkEditor(company, rerender) {
const form = document.createElement("form");
form.className = "board-edit";
form.autocomplete = "off";
const input = document.createElement("input");
input.type = "url";
input.spellcheck = false;
input.placeholder = "https://";
input.value = company.careers_url || "";
input.setAttribute("aria-label", `${company.name}'s careers page`);
const save = document.createElement("button");
save.type = "submit";
save.textContent = "Save";
const cancel = document.createElement("button");
cancel.type = "button";
cancel.className = "linky";
cancel.textContent = "Cancel";
cancel.addEventListener("click", () => { editing = null; rerender(); });
form.append(input, save, cancel);
form.addEventListener("submit", async (event) => {
event.preventDefault();
save.disabled = true;
try {
const updated = await api(`/api/companies/${encodeURIComponent(company.key)}/careers`,
{ method: "POST", body: { careers_url: input.value.trim() } });
company.careers_url = updated.careers_url;
editing = null;
rerender();
} catch (err) {
save.disabled = false;
}
});
return form;
}
/** The filter's options with their counts, kept on the chosen one. */
function drawFilter(all) {
const select = $("#w-filter");
const chosen = select.value || savedFilter();
select.replaceChildren();
for (const [value, label] of FILTERS) {
const option = document.createElement("option");
option.value = value;
option.textContent = `${label} (${all.filter((c) => matchesFilter(c, value)).length})`;
select.appendChild(option);
}
select.value = chosen;
}
function render() {
const all = watched();
drawFilter(all);
const q = $("#w-q").value.trim().toLowerCase();
const filter = $("#w-filter").value;
const rows = all
.filter((c) => !q || c.name.toLowerCase().includes(q)
|| (c.board || c.ats || "").includes(q) || (c.country || "").toLowerCase() === q)
.filter((c) => matchesFilter(c, filter));
// Overdue first on the list, never opened on top (the empty stamp sorts
// before any date); every other filter is by name.
rows.sort((a, b) => (filter === "yes"
? a.careers_opened_at.localeCompare(b.careers_opened_at) : 0)
|| a.name.localeCompare(b.name));
const body = $("#watchlist-list");
body.replaceChildren();
for (const company of rows) {
const row = document.createElement("div");
row.className = "crow";
const name = document.createElement("span");
name.className = "name";
name.textContent = company.name;
row.appendChild(name);
row.appendChild(ratingControl(company, render));
row.appendChild(subLine(company, render));
if (editing === company.key) row.appendChild(linkEditor(company, render));
body.appendChild(row);
}
$("#watchlist-count").textContent = count(rows.length, "company", "companies");
}
document.addEventListener("DOMContentLoaded", async () => {
if (!$("#watchlist-list")) return;
try {
await loadCompanies();
} catch (err) {
return;
}
$("#w-filter").value = savedFilter();
render();
$("#w-q").addEventListener("input", debounce(render, 150));
$("#w-filter").addEventListener("change", () => {
saveFilter($("#w-filter").value);
render();
});
});
})();
+19 -6
View File
@@ -107,8 +107,11 @@ CREATE TABLE IF NOT EXISTS role_tags (
-- yet. country is an ISO code and city the head office's. ats_slug is the -- yet. country is an ISO code and city the head office's. ats_slug is the
-- name that host knows the company by (the acme of acme.teamtailor.com), -- name that host knows the company by (the acme of acme.teamtailor.com),
-- '' where its URL carries none, kept for the parser written later. -- '' where its URL carries none, kept for the parser written later.
-- watch is the Watchlist's rating, global and not an agent's: NULL unrated, 1
-- 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), -- hand_reason is why a person reads the careers page (models.HAND_REASONS),
-- '' when nobody has to, and checked_at when one last did, '' for never. -- '' when nobody has to.
CREATE TABLE IF NOT EXISTS companies ( CREATE TABLE IF NOT EXISTS companies (
key TEXT PRIMARY KEY, key TEXT PRIMARY KEY,
name TEXT NOT NULL, name TEXT NOT NULL,
@@ -122,8 +125,9 @@ CREATE TABLE IF NOT EXISTS companies (
country TEXT NOT NULL DEFAULT '', country TEXT NOT NULL DEFAULT '',
city TEXT NOT NULL DEFAULT '', city TEXT NOT NULL DEFAULT '',
ats_slug TEXT NOT NULL DEFAULT '', ats_slug TEXT NOT NULL DEFAULT '',
hand_reason TEXT NOT NULL DEFAULT '', watch INTEGER CHECK (watch IN (0, 1)),
checked_at TEXT NOT NULL DEFAULT '' careers_opened_at TEXT NOT NULL DEFAULT '',
hand_reason TEXT NOT NULL DEFAULT ''
); );
-- The targets desk's runner hands to plugins. newsdesk's shape, with its two -- The targets desk's runner hands to plugins. newsdesk's shape, with its two
@@ -428,10 +432,19 @@ ALTER TABLE agents DROP COLUMN intent_key;
ALTER TABLE agents DROP COLUMN intent_vec; ALTER TABLE agents DROP COLUMN intent_vec;
ALTER TABLE scores ADD COLUMN prompt TEXT NOT NULL DEFAULT ''; ALTER TABLE scores ADD COLUMN prompt TEXT NOT NULL DEFAULT '';
"""), """),
(15, "companies.hand_reason and checked_at: the companies read by hand are a list " # The Watchlist's own rating, global and apart from an agent's affinity:
"with a reason and a date last looked at", """ # NULL not yet rated, 1 worth checking by hand, 0 not. Every company
# starts unrated.
(15, "companies.watch and careers_opened_at: the Watchlist's rating and "
"when its careers page was last opened", """
ALTER TABLE companies ADD COLUMN watch INTEGER CHECK (watch IN (0, 1));
ALTER TABLE companies ADD COLUMN careers_opened_at TEXT NOT NULL DEFAULT '';
"""),
# Why a person reads the company's careers page by hand, one of
# models.HAND_REASONS; '' when nobody has to. When it was last looked at
# is careers_opened_at.
(16, "companies.hand_reason: why a company is read by hand", """
ALTER TABLE companies ADD COLUMN hand_reason TEXT NOT NULL DEFAULT ''; ALTER TABLE companies ADD COLUMN hand_reason TEXT NOT NULL DEFAULT '';
ALTER TABLE companies ADD COLUMN checked_at TEXT NOT NULL DEFAULT '';
"""), """),
) )
+11 -11
View File
@@ -94,7 +94,7 @@ _EXCERPT_SOURCE = "COALESCE(NULLIF(roles.summary, ''), roles.description)"
_EXCERPT_RAW = 240 _EXCERPT_RAW = 240
_COMPANY_FIELDS = ("name", "domain", "status", "careers_url", "notes", "ats", "country", "city", _COMPANY_FIELDS = ("name", "domain", "status", "careers_url", "notes", "ats", "country", "city",
"ats_slug", "hand_reason", "checked_at") "ats_slug", "watch", "careers_opened_at", "hand_reason")
#: A company as the store serves it: the row and the asked-for agent's affinity. #: 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 _COMPANY_SELECT = """SELECT c.*, COALESCE(ac.affinity, 0) AS affinity FROM companies c
@@ -496,10 +496,11 @@ class Store:
"""Newest first by `posted_at`. `company` and `place` are """Newest first by `posted_at`. `company` and `place` are
case-insensitive substrings of the columns a board wrote — not the case-insensitive substrings of the columns a board wrote — not the
key, so a search does not have to know the exact slug a company folds key, so a search does not have to know the exact slug a company folds
to. `q` is matched word by word against `title`; a role must match to. `q` is matched word by word against `title` and `company`; a
every word. `function` and `remote` match a gate column exactly. role must match every word in one or the other. `function` and
`days` keeps only roles posted within that many days of now. `pay` `remote` match a gate column exactly. `days` keeps only roles posted
(a key of `PAY`) filters on `salary_state`. within that many days of now. `pay` (a key of `PAY`) filters on
`salary_state`.
`agent` says whose votes, hidden companies and scores are meant. Each `agent` says whose votes, hidden companies and scores are meant. Each
row carries that agent's `vote` and `voted_at`; `judged` (a key of row carries that agent's `vote` and `voted_at`; `judged` (a key of
@@ -653,8 +654,8 @@ class Store:
where.append("posted_at >= ?") where.append("posted_at >= ?")
params.append(_iso(self.clock() - timedelta(days=days))) params.append(_iso(self.clock() - timedelta(days=days)))
for word in (q or "").split(): for word in (q or "").split():
where.append("title LIKE ? ESCAPE '\\'") where.append("(title LIKE ? ESCAPE '\\' OR company LIKE ? ESCAPE '\\')")
params.append(_like(word)) params += [_like(word)] * 2
if judged: if judged:
if judged not in JUDGED: if judged not in JUDGED:
raise ValueError(f"judged is {', '.join(JUDGED)}, not {judged!r}") raise ValueError(f"judged is {', '.join(JUDGED)}, not {judged!r}")
@@ -1162,8 +1163,8 @@ class Store:
def add_company(self, name: str, *, key: str = "", domain: str = "", def add_company(self, name: str, *, key: str = "", domain: str = "",
status: str = "researching", careers_url: str = "", status: str = "researching", careers_url: str = "",
notes: str = "", ats: str = "", country: str = "", notes: str = "", ats: str = "", country: str = "",
city: str = "", ats_slug: str = "", hand_reason: str = "", city: str = "", ats_slug: str = "",
checked_at: str = "") -> Company: hand_reason: str = "") -> Company:
"""Raises ValueError on a key already taken or a `hand_reason` outside """Raises ValueError on a key already taken or a `hand_reason` outside
`HAND_REASONS`.""" `HAND_REASONS`."""
name = name.strip() name = name.strip()
@@ -1176,8 +1177,7 @@ class Store:
self._insert_company(conn, key, name, { self._insert_company(conn, key, name, {
"domain": domain, "status": status, "careers_url": careers_url, "domain": domain, "status": status, "careers_url": careers_url,
"notes": notes, "ats": ats, "country": country, "city": city, "notes": notes, "ats": ats, "country": country, "city": city,
"ats_slug": ats_slug, "hand_reason": hand_reason, "ats_slug": ats_slug, "hand_reason": hand_reason})
"checked_at": checked_at})
except sqlite3.IntegrityError as exc: except sqlite3.IntegrityError as exc:
raise ValueError(f"company {key!r} already exists") from exc raise ValueError(f"company {key!r} already exists") from exc
return self._company(key) return self._company(key)
+1 -1
View File
@@ -28,7 +28,7 @@
<button type="button" id="rail-toggle" title="Menu (f)" aria-label="Menu" <button type="button" id="rail-toggle" title="Menu (f)" aria-label="Menu"
aria-controls="rail"><span class="burger" aria-hidden="true"></span><span aria-controls="rail"><span class="burger" aria-hidden="true"></span><span
class="rail-toggle-label">Menu</span></button> class="rail-toggle-label">Menu</span></button>
<input type="search" id="search" placeholder="Search" aria-label="Search titles" <input type="search" id="search" placeholder="Search" aria-label="Search titles and companies"
autocomplete="off"> autocomplete="off">
{% endblock %} {% endblock %}
+5 -5
View File
@@ -28,18 +28,18 @@
</fieldset> </fieldset>
<fieldset class="where"> <fieldset class="where">
<legend>Where can the role be?</legend> <legend>Where can the role be?</legend>
<span class="hint">A role passes when it matches any line; with none filled in, it can be anywhere. A role whose location is not known yet ranks until extract reads the posting.</span> <span class="hint">Each line adds places. A role is kept when it fits at least one line, so a line more means more roles, never fewer. With every line empty a role can be anywhere. A role whose location is not known yet ranks until extract reads the posting.</span>
<div class="where-line"> <div class="where-line">
<span>In these countries</span> <span>Anywhere in</span>
<div id="a-countries"></div> <div id="a-countries"></div>
</div> </div>
<div class="where-line"> <div class="where-line">
<span>In these towns</span> <span>or in the towns</span>
<div id="a-towns"></div> <div id="a-towns"></div>
</div> </div>
<span class="hint">A town matches as part of the location, so Lund matches "Lund, Sweden": it is for towns outside the countries above.</span> <span class="hint">Towns are for places outside the countries above: with Denmark above, Malmö here adds Malmö to all of Denmark. A town inside a country above changes nothing, since the whole country is in already.</span>
<div class="where-line"> <div class="where-line">
<label class="inline"><input type="checkbox" id="a-remote"> Remote</label> <label class="inline"><input type="checkbox" id="a-remote"> or remote</label>
<select id="a-remote-scope" aria-label="Remote from where"> <select id="a-remote-scope" aria-label="Remote from where">
<option value="europe">within Europe</option> <option value="europe">within Europe</option>
<option value="anywhere">anywhere</option> <option value="anywhere">anywhere</option>
+21
View File
@@ -0,0 +1,21 @@
{% extends "base.html" %}
{% block title %}Watchlist — roledesk{% endblock %}
{% block content %}
<h1>Watchlist</h1>
<p class="lede">The companies roledesk knows but cannot read a board of, so their roles are not in Roles. Mark the ones worth checking by hand and open their careers page from here.</p>
<form class="filters" autocomplete="off" onsubmit="return false">
<input type="search" id="w-q" placeholder="Filter by name, host or country code" aria-label="Filter companies">
{# The options and their counts are drawn by watchlist.js, which also
remembers the choice. #}
<select id="w-filter" aria-label="Show"></select>
</form>
<p id="watchlist-count" class="count" role="status"></p>
<div id="watchlist-list" class="crows"></div>
{% endblock %}
{% block scripts %}
<script src="{{ asset('watchlist.js') }}"></script>
{% endblock %}
+62 -21
View File
@@ -306,14 +306,14 @@ class CompanyOut(BaseModel):
search listed its roles and somebody judged it (`Store.set_affinity`): search listed its roles and somebody judged it (`Store.set_affinity`):
no board, not even a detached one, and no `ats`, `careers_url`, `domain` no board, not even a detached one, and no `ats`, `careers_url`, `domain`
or `hand_reason`, which every way of following a company or listing it by or `hand_reason`, which every way of following a company or listing it by
hand writes one of (`jobs.sources.known_from_search_only`). `by_hand` hand writes one of (`jobs.sources.known_from_search_only`). `watch` and
marks a company on the list checked by hand: no board shown and not `careers_opened_at` are the Watchlist's (`Company`'s), the latter also
`from_search`. `hand_reason` says why (`app.models.HAND_REASONS`) and when a person last looked at the careers page. `by_hand` marks a company
`checked_at` when a person last looked at its careers page, "" for never.""" with no board shown that is not `from_search`, and `hand_reason` says why
it is read by hand (`app.models.HAND_REASONS`)."""
key: str key: str
name: str name: str
domain: str = ""
notes: str = "" notes: str = ""
board: str board: str
subscription_id: int | None = None subscription_id: int | None = None
@@ -324,11 +324,14 @@ class CompanyOut(BaseModel):
ats_slug: str = "" ats_slug: str = ""
careers_url: str = "" careers_url: str = ""
country: str = "" country: str = ""
city: str = ""
domain: str = ""
watch: int | None = None
careers_opened_at: str = ""
failing_since: str = "" failing_since: str = ""
failing_reason: str = "" failing_reason: str = ""
from_search: bool = False from_search: bool = False
hand_reason: str = "" hand_reason: str = ""
checked_at: str = ""
by_hand: bool = False by_hand: bool = False
@@ -357,13 +360,14 @@ def _company_outs(store: Store, agent: int | None) -> list[CompanyOut]:
sub_id, host, on, target = boards.get(c.key, (None, "", None, "")) sub_id, host, on, target = boards.get(c.key, (None, "", None, ""))
since, reason = failing.get(target, ("", "")) since, reason = failing.get(target, ("", ""))
from_search = jobs.sources.known_from_search_only(c, ever_boarded) from_search = jobs.sources.known_from_search_only(c, ever_boarded)
out.append(CompanyOut(key=c.key, name=c.name, domain=c.domain, notes=c.notes, out.append(CompanyOut(key=c.key, name=c.name, notes=c.notes, board=host,
board=host, subscription_id=sub_id, on=on, subscription_id=sub_id, on=on, affinity=c.affinity,
affinity=c.affinity, open_roles=counts.get(c.key, 0), open_roles=counts.get(c.key, 0), ats=c.ats,
ats=c.ats, ats_slug=c.ats_slug, careers_url=c.careers_url, ats_slug=c.ats_slug, careers_url=c.careers_url,
country=c.country, failing_since=since, failing_reason=reason, country=c.country, city=c.city, domain=c.domain,
watch=c.watch, careers_opened_at=c.careers_opened_at,
failing_since=since, failing_reason=reason,
from_search=from_search, hand_reason=c.hand_reason, from_search=from_search, hand_reason=c.hand_reason,
checked_at=c.checked_at,
by_hand=c.key not in boards and not from_search)) by_hand=c.key not in boards and not from_search))
return out return out
@@ -428,15 +432,6 @@ def edit_company(key: str, body: CompanyPatch, store: StoreDep) -> CompanyOut:
return _one_company(store, key) return _one_company(store, key)
@router.post("/companies/{key}/checked")
def company_checked(key: str, store: StoreDep) -> CompanyOut:
"""A person has just looked at the company's careers page."""
if store.company(key) is None:
raise HTTPException(404, f"no such company: {key}")
store.update_company(key, checked_at=store.now())
return _one_company(store, key)
@router.delete("/companies/{key}", status_code=204) @router.delete("/companies/{key}", status_code=204)
def remove_company(key: str, store: StoreDep) -> Response: def remove_company(key: str, store: StoreDep) -> Response:
"""Delete a company and every agent's stance on it. 409 for one with a """Delete a company and every agent's stance on it. 409 for one with a
@@ -549,6 +544,52 @@ def set_affinity(key: str, body: AffinityBody, store: StoreDep,
return AffinityOut(**company.model_dump(), score_job=job.id if job else None) return AffinityOut(**company.model_dump(), score_job=job.id if job else None)
class WatchBody(BaseModel):
#: True on the Watchlist's list, False not on it, None clears the rating.
watch: bool | None
@router.post("/companies/{key}/watch")
def set_watch(key: str, body: WatchBody, store: StoreDep) -> Company:
"""Rate a company for the Watchlist: 1 worth checking by hand, 0 not,
null back to unrated. Global, and apart from affinity. 404 for an
unknown key."""
watch = None if body.watch is None else int(body.watch)
try:
return store.update_company(key, watch=watch)
except KeyError:
raise HTTPException(404, f"no such company: {key}") from None
class CareersBody(BaseModel):
careers_url: str
@router.post("/companies/{key}/careers")
def set_careers_url(key: str, body: CareersBody, store: StoreDep) -> Company:
"""Set or correct where a company's careers page is; "" clears it. 422
for anything but an http(s) URL (`jobs.sources.check_careers_url`, the
rule the by-hand edit shares), 404 for an unknown key."""
try:
url = jobs.sources.check_careers_url(body.careers_url)
except ValueError as exc:
raise HTTPException(422, str(exc)) from exc
try:
return store.update_company(key, careers_url=url)
except KeyError:
raise HTTPException(404, f"no such company: {key}") from None
@router.post("/companies/{key}/opened")
def mark_careers_opened(key: str, store: StoreDep) -> Company:
"""Stamp that the company's careers page was just opened from the
Watchlist. 404 for an unknown key."""
try:
return store.update_company(key, careers_opened_at=store.now())
except KeyError:
raise HTTPException(404, f"no such company: {key}") from None
# ----------------------------------------------------------------- sources # ----------------------------------------------------------------- sources
class SourceOut(BaseModel): class SourceOut(BaseModel):
+8 -2
View File
@@ -1,6 +1,6 @@
"""The pages: two tabs, a cog, and three settings pages behind it. """The pages: three tabs, a cog, and three settings pages behind it.
`TABS` is the top bar, Roles and Applications, and `SETTINGS` is the rail `TABS` is the top bar, Roles, Applications and Watchlist, and `SETTINGS` is the rail
beside every page under the cog at `/settings/<name>`: Search agents, beside every page under the cog at `/settings/<name>`: Search agents,
Sources, Account. `base.html` renders the first, `settings/_rail.html` the Sources, Account. `base.html` renders the first, `settings/_rail.html` the
second, every page marks itself active by its own `path`, and adding one is second, every page marks itself active by its own `path`, and adding one is
@@ -68,6 +68,7 @@ class Tab:
TABS: tuple[Tab, ...] = ( TABS: tuple[Tab, ...] = (
Tab("/", "Roles", "roles.html"), Tab("/", "Roles", "roles.html"),
Tab("/applications", "Applications", "applications.html"), Tab("/applications", "Applications", "applications.html"),
Tab("/watchlist", "Watchlist", "watchlist.html"),
) )
#: The pages under the cog, in order; `settings/_rail.html` renders them. #: The pages under the cog, in order; `settings/_rail.html` renders them.
@@ -155,6 +156,11 @@ def applications(request: Request) -> HTMLResponse:
return page(request, "applications.html", status_options=STATUS_OPTIONS) return page(request, "applications.html", status_options=STATUS_OPTIONS)
@router.get("/watchlist", response_class=HTMLResponse)
def watchlist(request: Request) -> HTMLResponse:
return page(request, "watchlist.html")
@router.get("/settings", response_class=RedirectResponse) @router.get("/settings", response_class=RedirectResponse)
def settings() -> RedirectResponse: def settings() -> RedirectResponse:
return RedirectResponse(SETTINGS[0].path, status_code=302) return RedirectResponse(SETTINGS[0].path, status_code=302)
+3 -3
View File
@@ -4,7 +4,7 @@ Planned 2026-09-29. Three waves of work packages with disjoint files, built in p
## Why ## Why
187 of the 362 companies have no board attached: 32 on Teamtailor, whose parser landed today without the boards being attached, and 155 on a host the app cannot read or on no host it could name. They include LEGO, Novo Nordisk, Vestas, Danske Bank, SimCorp, Ørsted, Klarna and Zalando. A company the app cannot read is shown as "not readable yet" with a link that nobody can edit, so the owner has no list to work through by hand. 164 of the 362 companies have no board attached: 9 on Teamtailor whose career host is not found yet (the other 23 were attached today), and 155 on a host the app cannot read or on no host it could name. They include LEGO, Novo Nordisk, Vestas, Danske Bank, SimCorp, Ørsted, Klarna and Zalando. A company the app cannot read is shown as "not readable yet" with a link that nobody can edit, so the owner has no list to work through by hand.
## What the survey found ## What the survey found
@@ -12,7 +12,7 @@ Nine Sonnet agents read every one of the 155 career sites on 2026-09-29. Their n
| Route | Companies | Examples | | Route | Companies | Examples |
|---|---|---| |---|---|---|
| Board on a host the app reads already | 49 + 32 Teamtailor | Bosch, Wise, Ubisoft, Checkout.com, Lunar, DFDS, Voi, Remote | | Board on a host the app reads already | 49 + 9 Teamtailor | Bosch, Wise, Ubisoft, Checkout.com, Lunar, DFDS, Voi, Remote |
| SuccessFactors | 20 | Novo Nordisk, Vestas, Carlsberg, Pandora, Coloplast, Scania, SAP, Tryg | | SuccessFactors | 20 | Novo Nordisk, Vestas, Carlsberg, Pandora, Coloplast, Scania, SAP, Tryg |
| Workday | 19 | LEGO, Zeiss, SimCorp, Zendesk, Unity, Saxo Bank, Red Hat | | Workday | 19 | LEGO, Zeiss, SimCorp, Zendesk, Unity, Saxo Bank, Red Hat |
| Oracle | 4 | Danske Bank, Nokia, Sinch, Milestone | | Oracle | 4 | Danske Bank, Nokia, Sinch, Milestone |
@@ -120,7 +120,7 @@ Wave 2 is decided after wave 1 by the roles each company would add: a module per
## Planner, after the merges ## Planner, after the merges
- After WP1: write the survey into the live database and `seed/companies.json`: the verified `jobs_url` as `careers_url` for the 155, and the `hand_reason` of each company that stays by hand. - After WP1: write the survey into the live database and `seed/companies.json`: the verified `jobs_url` as `careers_url` for the 155, and the `hand_reason` of each company that stays by hand.
- Attach the 49 boards the survey found and the 32 Teamtailor boards with `set_board`, which fetches each before it lands. Not attached: Wallbox and Metacore (empty boards, possibly stale), Glovo, Cognigy. - Attach the 49 boards the survey found with `set_board`, which fetches each before it lands, and find the career host of the 9 Teamtailor companies left. Not attached: Wallbox and Metacore (empty boards, possibly stale), Glovo, Cognigy.
- After each host of wave 1: attach its boards, add it to `TRUSTED_POSTED_HOSTS` where its date is a posting date, and name it in `README.md`. - After each host of wave 1: attach its boards, add it to `TRUSTED_POSTED_HOSTS` where its date is a posting date, and name it in `README.md`.
- Run a full pull on a copy of the live database before the live one. - Run a full pull on a copy of the live database before the live one.
- Read one Workday and one SuccessFactors board from the deployed server, since every Workday host is behind Cloudflare and the survey ran from this machine. - Read one Workday and one SuccessFactors board from the deployed server, since every Workday host is behind Cloudflare and the survey ran from this machine.
+11
View File
@@ -85,6 +85,17 @@ def test_a_role_address_is_the_same_page_with_its_reader_open(
assert missing.status_code == 404 and "text/html" in missing.headers["content-type"] assert missing.status_code == 404 and "text/html" in missing.headers["content-type"]
def test_the_watchlist_is_the_third_tab_and_a_shell(client: TestClient) -> None:
page = client.get("/watchlist")
assert page.status_code == 200
assert 'href="/watchlist"\n class="active" aria-current="page">Watchlist' in page.text
assert 'id="watchlist-list"' in page.text and "/static/watchlist.js" in page.text
nav = page.text[page.text.index("<nav>"):page.text.index("</nav>")]
tabs = [t for t in ("Roles", "Applications", "Watchlist") if f">{t}</a>" in nav]
assert tabs == ["Roles", "Applications", "Watchlist"]
assert nav.count('aria-current="page"') == 1
def test_the_read_page_of_its_own_is_gone(client: TestClient) -> None: def test_the_read_page_of_its_own_is_gone(client: TestClient) -> None:
assert client.get("/static/role.js").status_code == 404 assert client.get("/static/role.js").status_code == 404
other = client.get("/applications").text other = client.get("/applications").text
+52 -26
View File
@@ -69,7 +69,7 @@ def test_schema_creates_on_an_empty_file(tmp_path: Path) -> None:
"application_events", "agents", "scores", "state"} <= tables "application_events", "agents", "scores", "state"} <= tables
assert "idx_roles_cluster" in indexes assert "idx_roles_cluster" in indexes
assert store.migrations_applied == [] assert store.migrations_applied == []
assert LATEST == 15 assert LATEST == 16
# A second open finds it current and applies nothing. # A second open finds it current and applies nothing.
assert Store(path).migrations_applied == [] assert Store(path).migrations_applied == []
@@ -88,18 +88,26 @@ def _columns(path: Path, table: str) -> list[tuple[str, str, int, str]]:
return [(r[1], r[2], r[3], r[4]) for r in conn.execute(f"PRAGMA table_info({table})")] return [(r[1], r[2], r[3], r[4]) for r in conn.execute(f"PRAGMA table_info({table})")]
def _undo_v15(conn: sqlite3.Connection) -> None: def _undo_v16(conn: sqlite3.Connection) -> None:
"""A fresh file put back to the v14 shape, without the by-hand columns of """A fresh file put back to the v15 shape: no by-hand reason on a
a company, and then to the v13 one by `_undo_v14`. Every downgrade below company."""
starts here, since v15 is the last migration."""
conn.execute("ALTER TABLE companies DROP COLUMN hand_reason") conn.execute("ALTER TABLE companies DROP COLUMN hand_reason")
conn.execute("ALTER TABLE companies DROP COLUMN checked_at")
_undo_v14(conn)
def _undo_v15(conn: sqlite3.Connection) -> None:
"""A fresh file put back to the v14 shape: no Watchlist columns on a
company."""
_undo_v16(conn)
conn.execute("ALTER TABLE companies DROP COLUMN watch")
conn.execute("ALTER TABLE companies DROP COLUMN careers_opened_at")
def _undo_v14(conn: sqlite3.Connection) -> None: def _undo_v14(conn: sqlite3.Connection) -> None:
"""A fresh file put back to the v13 shape: an agent's intent and its """A fresh file put back to the v13 shape: an agent's intent and its
cached vector on the agent row, no prompts, no prompt on a score.""" cached vector on the agent row, no prompts, no prompt on a score. Every
downgrade below starts here, after `_undo_v15`, since v16 is the last
migration."""
_undo_v15(conn)
conn.execute("DROP TABLE agent_prompts") conn.execute("DROP TABLE agent_prompts")
conn.execute("ALTER TABLE scores DROP COLUMN prompt") conn.execute("ALTER TABLE scores DROP COLUMN prompt")
conn.execute("ALTER TABLE agents ADD COLUMN intent TEXT NOT NULL DEFAULT ''") conn.execute("ALTER TABLE agents ADD COLUMN intent TEXT NOT NULL DEFAULT ''")
@@ -112,7 +120,7 @@ def test_a_v1_file_migrates_to_the_shape_a_new_file_has(tmp_path: Path) -> None:
Store(fresh) Store(fresh)
Store(old) Store(old)
with sqlite3.connect(old) as conn: with sqlite3.connect(old) as conn:
_undo_v15(conn) _undo_v14(conn)
conn.execute("DROP INDEX idx_roles_posted") # v9: indexes posted_at conn.execute("DROP INDEX idx_roles_posted") # v9: indexes posted_at
for column in ("permit", "languages", "extract_tries", "summary", "summarised_at", for column in ("permit", "languages", "extract_tries", "summary", "summarised_at",
"article_text", "article_at", "read_at", "posted_at", "salary_text"): "article_text", "article_at", "read_at", "posted_at", "salary_text"):
@@ -135,11 +143,28 @@ def test_a_v1_file_migrates_to_the_shape_a_new_file_has(tmp_path: Path) -> None:
assert sorted(_columns(old, table)) == sorted(_columns(fresh, table)) assert sorted(_columns(old, table)) == sorted(_columns(fresh, table))
def test_a_v14_file_gains_the_watchlist_columns_and_leaves_companies_unrated(
tmp_path: Path) -> None:
path = tmp_path / "v14.db"
Store(path).add_company("Acme", ats="teamtailor", country="DK", careers_url="https://a.example")
with sqlite3.connect(path) as conn:
_undo_v15(conn)
conn.execute("PRAGMA user_version = 14")
migrated = Store(path)
assert migrated.migrations_applied == [15, 16]
acme = migrated.company("acme")
assert acme is not None
assert (acme.ats, acme.careers_url) == ("teamtailor", "https://a.example")
assert (acme.watch, acme.careers_opened_at) == (None, "")
def test_a_v8_file_gains_ats_slug_and_keeps_its_companies(tmp_path: Path) -> None: def test_a_v8_file_gains_ats_slug_and_keeps_its_companies(tmp_path: Path) -> None:
path = tmp_path / "v8.db" path = tmp_path / "v8.db"
Store(path).add_company("Acme", ats="teamtailor", country="DK") Store(path).add_company("Acme", ats="teamtailor", country="DK")
with sqlite3.connect(path) as conn: with sqlite3.connect(path) as conn:
_undo_v15(conn) _undo_v14(conn)
conn.execute("ALTER TABLE companies DROP COLUMN ats_slug") conn.execute("ALTER TABLE companies DROP COLUMN ats_slug")
conn.execute("DROP INDEX idx_roles_posted") # v10, which follows conn.execute("DROP INDEX idx_roles_posted") # v10, which follows
conn.execute("ALTER TABLE roles DROP COLUMN posted_at") conn.execute("ALTER TABLE roles DROP COLUMN posted_at")
@@ -158,7 +183,7 @@ def _downgrade_to_v4(path: Path) -> None:
"""A fresh file put back to the v4 shape: votes on the role, affinity on """A fresh file put back to the v4 shape: votes on the role, affinity on
the company, no read state, no tags, no per-agent tables.""" the company, no read state, no tags, no per-agent tables."""
with sqlite3.connect(path) as conn: with sqlite3.connect(path) as conn:
_undo_v15(conn) _undo_v14(conn)
conn.execute("ALTER TABLE roles DROP COLUMN read_at") conn.execute("ALTER TABLE roles DROP COLUMN read_at")
conn.execute("DROP INDEX idx_roles_posted") # v9: indexes posted_at conn.execute("DROP INDEX idx_roles_posted") # v9: indexes posted_at
conn.execute("ALTER TABLE roles DROP COLUMN posted_at") # v9 conn.execute("ALTER TABLE roles DROP COLUMN posted_at") # v9
@@ -270,7 +295,7 @@ def test_v10_backfills_posted_at_by_the_same_rule_upsert_uses(
assert before_trusted is not None and before_untrusted is not None assert before_trusted is not None and before_untrusted is not None
with sqlite3.connect(path) as conn: with sqlite3.connect(path) as conn:
_undo_v15(conn) _undo_v14(conn)
conn.execute("DROP INDEX idx_roles_posted") conn.execute("DROP INDEX idx_roles_posted")
conn.execute("ALTER TABLE roles DROP COLUMN posted_at") conn.execute("ALTER TABLE roles DROP COLUMN posted_at")
conn.execute("ALTER TABLE roles DROP COLUMN salary_text") # v12 conn.execute("ALTER TABLE roles DROP COLUMN salary_text") # v12
@@ -298,7 +323,7 @@ def test_v13_recomputes_country_from_place_unless_the_board_or_extract_set_it(
for item in (wrong, several, given, extracted): for item in (wrong, several, given, extracted):
store.upsert_role(item) store.upsert_role(item)
with sqlite3.connect(path) as conn: with sqlite3.connect(path) as conn:
_undo_v15(conn) _undo_v14(conn)
conn.execute("UPDATE roles SET country = 'US' WHERE place = 'Bogota, CO'") conn.execute("UPDATE roles SET country = 'US' WHERE place = 'Bogota, CO'")
conn.execute("UPDATE roles SET country = '' WHERE uid = ?", (several.uid,)) conn.execute("UPDATE roles SET country = '' WHERE uid = ?", (several.uid,))
conn.execute("UPDATE roles SET extracted_at = '2026-09-23' WHERE uid = ?", conn.execute("UPDATE roles SET extracted_at = '2026-09-23' WHERE uid = ?",
@@ -325,7 +350,7 @@ def test_v14_makes_each_intent_the_agents_one_prompt_with_its_vector(tmp_path: P
store.replace_scores(backend.id, [(uid, 0.7, "")]) store.replace_scores(backend.id, [(uid, 0.7, "")])
vec = np.asarray([0.6, 0.8], dtype=np.float32) vec = np.asarray([0.6, 0.8], dtype=np.float32)
with sqlite3.connect(path) as conn: with sqlite3.connect(path) as conn:
_undo_v15(conn) _undo_v14(conn)
conn.execute("UPDATE agents SET intent = 'python backend', intent_key = 'k', " conn.execute("UPDATE agents SET intent = 'python backend', intent_key = 'k', "
"intent_vec = ? WHERE id = ?", (pack(vec), backend.id)) "intent_vec = ? WHERE id = ?", (pack(vec), backend.id))
conn.execute("UPDATE agents SET intent = ' \n ' WHERE id = ?", (blank.id,)) conn.execute("UPDATE agents SET intent = ' \n ' WHERE id = ?", (blank.id,))
@@ -333,7 +358,7 @@ def test_v14_makes_each_intent_the_agents_one_prompt_with_its_vector(tmp_path: P
migrated = Store(path) migrated = Store(path)
assert migrated.migrations_applied == [14, 15] assert migrated.migrations_applied == [14, 15, 16]
assert migrated.agent(backend.id).prompts == [ # type: ignore[union-attr] assert migrated.agent(backend.id).prompts == [ # type: ignore[union-attr]
Prompt(name="Backend", text="python backend")] Prompt(name="Backend", text="python backend")]
assert migrated.agent(blank.id).prompts == [] # type: ignore[union-attr] assert migrated.agent(blank.id).prompts == [] # type: ignore[union-attr]
@@ -347,22 +372,21 @@ def test_v14_makes_each_intent_the_agents_one_prompt_with_its_vector(tmp_path: P
assert not {"intent", "intent_key", "intent_vec"} & columns assert not {"intent", "intent_key", "intent_vec"} & columns
def test_v15_gives_a_company_no_reason_and_no_check_and_keeps_its_row(tmp_path: Path) -> None: def test_v16_gives_a_company_no_reason_and_keeps_its_row(tmp_path: Path) -> None:
fresh, path = tmp_path / "fresh.db", tmp_path / "v14.db" fresh, path = tmp_path / "fresh.db", tmp_path / "v15.db"
Store(fresh) Store(fresh)
Store(path).add_company("Acme", careers_url="https://acme.example/jobs", notes="met them") Store(path).add_company("Acme", careers_url="https://acme.example/jobs", notes="met them")
with sqlite3.connect(path) as conn: with sqlite3.connect(path) as conn:
conn.execute("ALTER TABLE companies DROP COLUMN hand_reason") _undo_v16(conn)
conn.execute("ALTER TABLE companies DROP COLUMN checked_at") conn.execute("PRAGMA user_version = 15")
conn.execute("PRAGMA user_version = 14")
migrated = Store(path) migrated = Store(path)
assert migrated.migrations_applied == [15] assert migrated.migrations_applied == [16]
acme = migrated.company("acme") acme = migrated.company("acme")
assert acme is not None assert acme is not None
assert (acme.careers_url, acme.notes, acme.hand_reason, acme.checked_at) == ( assert (acme.careers_url, acme.notes, acme.hand_reason) == (
"https://acme.example/jobs", "met them", "", "") "https://acme.example/jobs", "met them", "")
assert sorted(_columns(path, "companies")) == sorted(_columns(fresh, "companies")) assert sorted(_columns(path, "companies")) == sorted(_columns(fresh, "companies"))
@@ -695,6 +719,9 @@ def test_roles_filters_q_function_remote_and_days(store: Store, clock: Clock) ->
function="sales")) function="sales"))
assert [r.source_id for r in store.roles(q="senior engineer")] == ["2", "1"] assert [r.source_id for r in store.roles(q="senior engineer")] == ["2", "1"]
assert [r.source_id for r in store.roles(q="backend nonsense")] == [] assert [r.source_id for r in store.roles(q="backend nonsense")] == []
# A word may match the company instead of the title, each on its own.
assert [r.source_id for r in store.roles(q="acme engineer")] == ["2", "1"]
assert [r.source_id for r in store.roles(q="acme nonsense")] == []
assert [r.source_id for r in store.roles(function="engineering")] == ["1"] assert [r.source_id for r in store.roles(function="engineering")] == ["1"]
assert [r.source_id for r in store.roles(remote="remote")] == ["1"] assert [r.source_id for r in store.roles(remote="remote")] == ["1"]
assert [r.source_id for r in store.roles(company="ac")] == ["2", "1"] assert [r.source_id for r in store.roles(company="ac")] == ["2", "1"]
@@ -1009,9 +1036,8 @@ def test_companies_crud(store: Store) -> None:
assert store.company("acme") is None assert store.company("acme") is None
def test_a_company_takes_a_reason_from_the_vocabulary_and_a_check_date(store: Store) -> None: def test_a_company_takes_a_reason_from_the_vocabulary(store: Store) -> None:
acme = store.add_company("Acme", hand_reason="robots", checked_at="2026-09-01T00:00:00+00:00") assert store.add_company("Acme", hand_reason="robots").hand_reason == "robots"
assert (acme.hand_reason, acme.checked_at) == ("robots", "2026-09-01T00:00:00+00:00")
assert store.add_company("Plain").hand_reason == "" assert store.add_company("Plain").hand_reason == ""
with pytest.raises(ValueError, match="hand_reason is one of"): with pytest.raises(ValueError, match="hand_reason is one of"):
store.add_company("Odd", hand_reason="lazy") store.add_company("Odd", hand_reason="lazy")
+74 -17
View File
@@ -427,12 +427,12 @@ def test_companies_lists_board_and_open_role_count(
res = client.get("/api/companies") res = client.get("/api/companies")
assert res.status_code == 200 assert res.status_code == 200
[row] = [c for c in res.json() if c["key"] == "acme"] [row] = [c for c in res.json() if c["key"] == "acme"]
assert row == {"key": "acme", "name": "Acme", "domain": "", "notes": "", assert row == {"key": "acme", "name": "Acme", "notes": "", "board": "greenhouse",
"board": "greenhouse", "subscription_id": sub.id, "on": True, "subscription_id": sub.id, "on": True, "affinity": 0, "open_roles": 1,
"affinity": 0, "open_roles": 1, "ats": "greenhouse", "ats_slug": "", "ats": "greenhouse", "ats_slug": "", "careers_url": "",
"careers_url": "", "country": "DK", "failing_since": "", "country": "DK", "city": "", "domain": "", "watch": None,
"failing_reason": "", "from_search": False, "hand_reason": "", "careers_opened_at": "", "failing_since": "", "failing_reason": "",
"checked_at": "", "by_hand": False} "from_search": False, "hand_reason": "", "by_hand": False}
[other] = [c for c in res.json() if c["key"] == "other"] [other] = [c for c in res.json() if c["key"] == "other"]
assert (other["board"], other["subscription_id"], other["on"], other["ats"]) == ( assert (other["board"], other["subscription_id"], other["on"], other["ats"]) == (
"", None, None, "") "", None, None, "")
@@ -555,6 +555,53 @@ def test_post_score_answers_with_the_job_to_wait_for(client: TestClient, queue:
assert queue.jobs.get(res.json()["id"]).kind == "score" assert queue.jobs.get(res.json()["id"]).kind == "score"
# ------------------------------------------------------------- watchlist
def test_the_watchlist_rating_is_global_and_leaves_affinity_alone(
client: TestClient, store: Store) -> None:
store.add_company("Acme", ats="workday")
agent = store.save_agent("A")
store.set_affinity(agent.id, "acme", 1)
for watch, stored in ((True, 1), (False, 0), (None, None)):
res = client.post("/api/companies/acme/watch", json={"watch": watch})
assert res.status_code == 200 and res.json()["watch"] == stored
listed = client.get("/api/companies").json()[0]
assert (listed["watch"], listed["affinity"]) == (stored, 1)
def test_the_careers_page_is_set_cleared_and_must_be_a_web_address(
client: TestClient, store: Store) -> None:
store.add_company("Acme")
res = client.post("/api/companies/acme/careers", json={"careers_url": "https://a.example/jobs"})
assert res.status_code == 200 and res.json()["careers_url"] == "https://a.example/jobs"
for bad in ("javascript:alert(1)", "a.example/jobs", "ftp://a.example"):
assert client.post("/api/companies/acme/careers",
json={"careers_url": bad}).status_code == 422
assert store.company("acme").careers_url == "https://a.example/jobs"
cleared = client.post("/api/companies/acme/careers", json={"careers_url": ""})
assert cleared.status_code == 200 and store.company("acme").careers_url == ""
def test_opening_the_careers_page_stamps_the_time(client: TestClient, store: Store) -> None:
store.add_company("Acme")
assert client.get("/api/companies").json()[0]["careers_opened_at"] == ""
res = client.post("/api/companies/acme/opened")
assert res.status_code == 200
assert res.json()["careers_opened_at"] == store.company("acme").careers_opened_at != ""
assert client.get("/api/companies").json()[0]["careers_opened_at"] != ""
def test_the_watchlist_endpoints_404_for_an_unknown_company(client: TestClient) -> None:
assert client.post("/api/companies/nope/watch", json={"watch": True}).status_code == 404
assert client.post("/api/companies/nope/careers",
json={"careers_url": "https://a.example"}).status_code == 404
assert client.post("/api/companies/nope/opened").status_code == 404
# ----------------------------------------------------------- applications # ----------------------------------------------------------- applications
def test_save_creates_an_application_with_a_saved_event( def test_save_creates_an_application_with_a_saved_event(
@@ -632,7 +679,7 @@ def test_the_applications_page_has_no_next_column(client: TestClient) -> None:
# -------------------------------------------------------------------- tabs # -------------------------------------------------------------------- tabs
def test_every_page_renders_with_the_whole_nav(client: TestClient) -> None: def test_every_page_renders_with_the_whole_nav(client: TestClient) -> None:
assert [t.label for t in TABS] == ["Roles", "Applications"] assert [t.label for t in TABS] == ["Roles", "Applications", "Watchlist"]
assert [t.label for t in SETTINGS] == ["Search agents", "Sources", "Account"] assert [t.label for t in SETTINGS] == ["Search agents", "Sources", "Account"]
assert all(t.path.startswith("/settings/") for t in SETTINGS) assert all(t.path.startswith("/settings/") for t in SETTINGS)
for tab in (*TABS, *SETTINGS): for tab in (*TABS, *SETTINGS):
@@ -1231,8 +1278,9 @@ def test_a_company_is_added_by_hand_with_a_reason_and_a_link(
"key": "revolut", "name": "Revolut Ltd", "domain": "", "notes": "wants a login", "key": "revolut", "name": "Revolut Ltd", "domain": "", "notes": "wants a login",
"board": "", "subscription_id": None, "on": None, "affinity": 0, "open_roles": 0, "board": "", "subscription_id": None, "on": None, "affinity": 0, "open_roles": 0,
"ats": "", "ats_slug": "", "careers_url": "https://revolut.example/careers", "ats": "", "ats_slug": "", "careers_url": "https://revolut.example/careers",
"country": "", "failing_since": "", "failing_reason": "", "from_search": False, "country": "", "city": "", "watch": None, "careers_opened_at": "",
"hand_reason": "added", "checked_at": "", "by_hand": True} "failing_since": "", "failing_reason": "", "from_search": False,
"hand_reason": "added", "by_hand": True}
assert store.company("revolut").hand_reason == "added" # type: ignore[union-attr] assert store.company("revolut").hand_reason == "added" # type: ignore[union-attr]
other = client.post("/api/companies", json={"name": "Meta", "hand_reason": "blocked"}) other = client.post("/api/companies", json={"name": "Meta", "hand_reason": "blocked"})
@@ -1316,17 +1364,26 @@ def test_a_company_with_a_board_keeps_its_name_and_takes_the_other_edits(
assert store.company("acme").name == "Acme" # type: ignore[union-attr] assert store.company("acme").name == "Acme" # type: ignore[union-attr]
def test_checking_a_company_stamps_now(client: TestClient, store: Store) -> None: def test_the_watchlists_careers_link_and_the_by_hand_edit_share_one_url_rule(
client: TestClient, store: Store) -> None:
store.add_company("Acme", key="acme")
for bad in ("https://", "javascript:alert(1)"):
posted = client.post("/api/companies/acme/careers", json={"careers_url": bad})
patched = client.patch("/api/companies/acme", json={"careers_url": bad})
assert posted.status_code == patched.status_code == 422
assert posted.json() == patched.json()
assert store.company("acme").careers_url == "" # type: ignore[union-attr]
def test_opening_a_by_hand_company_shows_when_it_was_last_looked_at(
client: TestClient, store: Store) -> None:
clock = Clock() clock = Clock()
store.clock = clock store.clock = clock
store.add_company("Acme", key="acme", hand_reason="unread") store.add_company("Acme", key="acme", hand_reason="unread")
res = client.post("/api/companies/acme/checked") assert client.post("/api/companies/acme/opened").status_code == 200
assert res.status_code == 200 [row] = client.get("/api/companies").json()
assert res.json()["checked_at"] == "2026-09-23T09:00:00+00:00" assert (row["by_hand"], row["careers_opened_at"]) == (True, "2026-09-23T09:00:00+00:00")
clock.tick(48) assert client.post("/api/companies/acme/checked").status_code in (404, 405)
assert client.post("/api/companies/acme/checked").json()["checked_at"] == (
"2026-09-25T09:00:00+00:00")
assert client.post("/api/companies/nope/checked").status_code == 404
def test_a_company_is_deleted_unless_it_is_read( def test_a_company_is_deleted_unless_it_is_read(