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:
1 parent
91d15fcc7d
commit
b2c8c08f7f
6 files changed
+78
-15
No files matched your search
@@ -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
@@ -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
@@ -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
@@ -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)
|
||||
|
||||
@@ -58,6 +58,8 @@ What was decided for roledesk and the one reason for each. The longer reasoning
|
||||
|
||||
**A company row carries `ats`, `ats_slug`, `country` and `city`.** `ats` is what discovery found whether or not the app reads it; a company with an `ats` and no board subscription is one it cannot read yet. `ats_slug` is the name that host knows the company by (the `acme` of `acme.teamtailor.com`), so the parser written later has its targets without a second discovery run; with a board it is the board's slug. `country` and `city` come from the seed for now and are the first of the company facts the feed will filter by; funding, size and industry come from a source that has them, not from a column filled by hand.
|
||||
|
||||
**An employer known only from a search gets a company row when it is first judged, and the Companies list derives that it is one.** Jobindex and Adzuna roles carry a `company_key` with no row in `companies` (67 keys with open roles on the live data of 2026-09-29), so they could not be hidden or liked. `Store.set_affinity` now creates a row for a key that has roles, named by the name its roles give most often, with nothing else set, and the reader draws the control for any role with a `company_key`. Such a row has no board, `ats` or `careers_url`, which the Companies list read as "board not found" and put under "Not readable yet". The rule: a company with no `ats` subscription (not even a detached one) and no `ats`, `careers_url` or `domain` is from job boards (`from_search` on `/api/companies`), labelled so and left out of that filter. Derived rather than a column, because every way of following a company writes one of those (the seed and discover a domain, Follow and `set-board` a board, which detaching hides but keeps), and a search-only company that later gets a domain or a board is followed from then on without a flag to flip.
|
||||
|
||||
**Jobindex and Adzuna, not Jobnet or Jooble.** Jobindex, Denmark's largest board, has an RSS twin for every search page, with phrase and required-word syntax and a region id; no key. Adzuna has a documented API with a free key for the UK and most of the EU, but no Denmark. Jobnet's search endpoint answers 401 outside its own site's session, and Jooble gives a key only on a manual application and answered a Cloudflare challenge. LinkedIn and Indeed have no public search API.
|
||||
|
||||
**A search closes a role only when it listed everything.** A search result is not a complete list, so a role missing from one run has not closed. An Adzuna search listed everything when it read as many distinct results as the `count` it states; a Jobindex search, whose feed states no count, when a page within its page limit came back with fewer than 20 items, counted before the parser drops any, so one malformed item does not pass for the end. Such a search closes like a board; the rest close once no search has listed them for 21 days. A Jobindex answer with no RSS channel raises instead of reading as an empty, complete search. A role two searches found belongs to the last one that listed it, so one search never closes a role the other still lists.
|
||||
|
||||
+36
-2
@@ -389,7 +389,7 @@ def test_companies_lists_board_and_open_role_count(
|
||||
sub = store.add_subscription("ats", "greenhouse:acme", company="Acme", board="greenhouse")
|
||||
store.add_company("Acme", key="acme", ats="greenhouse", country="DK")
|
||||
store.upsert_role(posting("1", company="Acme"), sub)
|
||||
store.add_company("Other", key="other") # no board found
|
||||
store.add_company("Other", key="other", domain="other.example") # no board found
|
||||
store.add_company("Novo", key="novo", ats="successfactors", # followed, not readable
|
||||
careers_url="https://novo.example/careers")
|
||||
|
||||
@@ -399,13 +399,47 @@ def test_companies_lists_board_and_open_role_count(
|
||||
assert row == {"key": "acme", "name": "Acme", "board": "greenhouse",
|
||||
"subscription_id": sub.id, "on": True, "affinity": 0, "open_roles": 1,
|
||||
"ats": "greenhouse", "ats_slug": "", "careers_url": "",
|
||||
"country": "DK", "failing_since": "", "failing_reason": ""}
|
||||
"country": "DK", "failing_since": "", "failing_reason": "",
|
||||
"from_search": False}
|
||||
[other] = [c for c in res.json() if c["key"] == "other"]
|
||||
assert (other["board"], other["subscription_id"], other["on"], other["ats"]) == (
|
||||
"", None, None, "")
|
||||
[novo] = [c for c in res.json() if c["key"] == "novo"]
|
||||
assert (novo["board"], novo["subscription_id"], novo["ats"], novo["careers_url"]) == (
|
||||
"", None, "successfactors", "https://novo.example/careers")
|
||||
assert not any(c["from_search"] for c in res.json())
|
||||
|
||||
|
||||
def test_judging_a_company_known_only_from_a_search_creates_its_row(
|
||||
client: TestClient, store: Store) -> None:
|
||||
"""Jobindex and Adzuna employers have roles and no company row. The first
|
||||
affinity change makes a minimal one, named by its roles, which the
|
||||
Companies list marks `from_search`, unlike a followed company without a
|
||||
board, and a company whose board was detached."""
|
||||
store.save_agent("A")
|
||||
search = store.add_subscription("search", "jobindex:cph", label="cph", board="jobindex")
|
||||
for i, name in enumerate(("Novo Nordisk A/S", "Novo Nordisk A/S", "NOVO NORDISK A/S")):
|
||||
item = posting(f"n{i}", company=name)
|
||||
item.source = "search"
|
||||
store.upsert_role(item, search)
|
||||
key = "novo-nordisk"
|
||||
assert store.company(key) is None
|
||||
|
||||
res = client.post(f"/api/companies/{key}/affinity", json={"affinity": -1})
|
||||
assert res.status_code == 200, res.text
|
||||
assert (res.json()["name"], res.json()["affinity"]) == ("Novo Nordisk A/S", -1)
|
||||
assert client.post("/api/companies/nobody/affinity", json={"affinity": 1}).status_code == 404
|
||||
|
||||
store.add_company("Pleo", key="pleo", domain="pleo.io") # followed, no board found
|
||||
sub = store.add_subscription("ats", "lever:gone", company="Gone", board="lever")
|
||||
store.add_company("Gone", key="gone")
|
||||
store.set_company_board("gone", "") # detached
|
||||
assert not store.subscription(sub.id).show # type: ignore[union-attr]
|
||||
rows = {c["key"]: c for c in client.get("/api/companies").json()}
|
||||
assert rows["gone"]["board"] == ""
|
||||
assert rows[key]["from_search"] and rows[key]["open_roles"] == 3
|
||||
assert (rows[key]["board"], rows[key]["ats"], rows[key]["careers_url"]) == ("", "", "")
|
||||
assert not rows["pleo"]["from_search"] and not rows["gone"]["from_search"]
|
||||
|
||||
|
||||
def test_companies_say_since_when_a_board_fails(client: TestClient, store: Store,
|
||||
|
||||
Reference in new issue
Block a user