Judge an employer known only from a search; the Companies list says "from job boards"

Store.set_affinity creates a minimal company row (key, and the name its roles
give most often) for a key with roles and no row, so a Jobindex or Adzuna
employer can be hidden or liked; the reader draws the control for any role
with a company_key and reloads the company list after the first change.

/api/companies derives from_search: no ats subscription (detached included)
and no ats, careers_url or domain. companies.js labels it "from job boards"
and keeps it out of "Not readable yet".

Co-Authored-By: Claude Opus <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Opus committed 2026-09-29 15:19:55 +02:00
1 parent 91d15fcc7d
commit b2c8c08f7f
6 files changed
+78 -15

No files matched your search

+6 -3
View File
@@ -71,9 +71,12 @@
: "own site";
sub.appendChild(badge);
sub.append(" · not readable yet");
} else if (company.from_search) {
// Nobody followed it: its roles came from a search, and it was judged.
sub.append("from job boards");
} else {
// Every row comes from the seed, Follow or discover: none of them
// found where this company posts its roles.
// Followed by the seed, Follow or discover, and none of them found
// where this company posts its roles.
sub.append("board not found");
}
if (company.careers_url && !company.board) {
@@ -214,7 +217,7 @@
case "hidden": return company.affinity === -1;
case "on": return company.on === true;
case "off": return company.on === false;
case "unreadable": return company.subscription_id == null;
case "unreadable": return company.subscription_id == null && !company.from_search;
default: return true;
}
}
+6 -4
View File
@@ -800,12 +800,14 @@
}
/* The company's ★ ▲ ⊘, the one place a company is judged outside the
Companies page. A company seen only through a search has no row of its
own to judge. A change dims or undims its rows in the feed. */
Companies page. A company seen only through a search has no row until
its first change creates one, so the list is reloaded then. A change
dims or undims its rows in the feed. */
function renderAffinity(slot, r) {
const company = companies.get(r.company_key);
if (!company) { slot.replaceChildren(); return; }
slot.replaceChildren(affinityControl(r.company_key, company.affinity, () => {
if (!r.company_key) { slot.replaceChildren(); return; }
slot.replaceChildren(affinityControl(r.company_key, company ? company.affinity : 0, async () => {
if (!company) await loadCompanies(state.filter.agent).catch(() => {});
renderAffinity(slot, r);
renderFeed();
}, state.filter.agent));
+15 -2
View File
@@ -1067,11 +1067,24 @@ class Store:
"""One agent's stance on a company: -1 hidden, 0 neutral, 1 liked, 2
favourite. 0 deletes the row, since no row means neutral. Returns the
company with this agent's affinity. Raises ValueError for another
value and KeyError for an unknown company or agent."""
value and KeyError for an unknown company or agent.
A key with roles and no company row, an employer known only from a
search, gets a row here holding only its key and the name its roles
give it, the most frequent one: nothing else can be judged without
one. It has no board, `ats`, `careers_url` or `domain`, which is how
the Companies list tells it from a followed company."""
_check_affinity(affinity)
with self.transaction() as conn:
self._known(conn, "companies", "key", key)
self._known(conn, "agents", "id", agent_id)
if conn.execute("SELECT 1 FROM companies WHERE key=?", (key,)).fetchone() is None:
named = conn.execute(
"""SELECT company FROM roles WHERE company_key=? AND company<>''
GROUP BY company ORDER BY count(*) DESC, max(last_seen) DESC
LIMIT 1""", (key,)).fetchone()
if named is None:
raise KeyError(key)
self._insert_company(conn, key, named[0], {})
if affinity == 0:
conn.execute("DELETE FROM agent_companies WHERE agent_id=? AND company_key=?",
(agent_id, key))
+13 -4
View File
@@ -268,7 +268,10 @@ class CompanyOut(BaseModel):
no `board` and an `ats` is one the app cannot read yet; `careers_url` is
where a person can. `failing_since` and `failing_reason` say since when
the board has failed on every fetch and why it last did, both empty
while it answers."""
while it answers. `from_search` marks a row that exists only because a
search listed its roles and somebody judged it (`Store.set_affinity`):
no board, not even a detached one, and no `ats`, `careers_url` or
`domain`, which every way of following a company writes one of."""
key: str
name: str
@@ -283,6 +286,7 @@ class CompanyOut(BaseModel):
country: str = ""
failing_since: str = ""
failing_reason: str = ""
from_search: bool = False
def _company_boards(store: Store) -> dict[str, tuple[int, str, bool, str]]:
@@ -305,6 +309,7 @@ def list_companies(store: StoreDep, agent: int | None = None) -> list[CompanyOut
"""Every company, with `affinity` as `agent` (the default agent when
absent) has it; 0 throughout when there is no agent."""
boards = _company_boards(store)
ever_boarded = {company_key(s.company) for s in store.subscriptions(source="ats")}
counts = store.open_role_counts()
failing = jobs.pull.failing_boards(store)
out = []
@@ -316,7 +321,9 @@ def list_companies(store: StoreDep, agent: int | None = None) -> list[CompanyOut
open_roles=counts.get(c.key, 0), ats=c.ats,
ats_slug=c.ats_slug, careers_url=c.careers_url,
country=c.country,
failing_since=since, failing_reason=reason))
failing_since=since, failing_reason=reason,
from_search=not (c.key in ever_boarded or c.ats
or c.careers_url or c.domain)))
return out
@@ -410,8 +417,10 @@ class AffinityOut(Company):
def set_affinity(key: str, body: AffinityBody, store: StoreDep,
queue: QueueDep) -> AffinityOut:
"""-1 hidden, 0 neutral, 1 liked, 2 favourite, for `body.agent` or the
default agent. A change here is not seen in Best match until `score` has
run, so it queues one (`_score_after_change`) and answers with its id."""
default agent. A key with roles and no company row gets one first (see
`Store.set_affinity`); 404 for a key with neither. A change here is not
seen in Best match until `score` has run, so it queues one
(`_score_after_change`) and answers with its id."""
if body.affinity not in AFFINITY:
raise HTTPException(422, "affinity is -1, 0, 1 or 2")
owner = _agent_or_default(store, body.agent)