Find roles by search, not only by company: Jobindex and Adzuna searches

The ats boards only read companies someone listed, and the seed list is
US-centred: 31 of 29,000 open roles were in Denmark. A `search` plugin runs
saved queries on boards that span companies, pulled in the same task as the
boards: Jobindex (Denmark, RSS, no key) and Adzuna (UK and most of the EU,
free key, built to its documented API). Jobnet and Jooble were checked and
left out.

`country` is now filled from the board's location line by a lookup, with EU
for Europe-wide roles, so country gates work without extract. `app companies
prune --in` unsubscribes boards with no open role in a region. The starter
agents and searches are Copenhagen and Europe.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Opus 5.5 committed 2026-09-23 19:55:50 +02:00
1 parent bfab68c878
commit 047f7cd8ad
17 files changed
+1293 -72

No files matched your search

+40 -3
View File
@@ -22,8 +22,8 @@ import numpy as np
from desk.models import Item
from app.models import (
AFFINITY, REMOTE, STATUSES, Agent, Application, ApplicationEvent, Candidate,
Company, Gate, Role, ScoredRole, Subscription, Weights, company_key, place_key,
title_key,
Company, Gate, Role, ScoredRole, Subscription, Weights, company_key, country_of,
place_key, title_key,
)
from app.storage import schema
@@ -212,7 +212,8 @@ class Store:
`first_seen` and `created_at` are written on insert only; `last_seen` on
every call, and a role seen again is open again. The gate columns come
from `item.raw` under their own names, with `company` falling back to
the subscription's; an empty value never overwrites a filled column.
the subscription's and `country` to what `place` names; an empty value
never overwrites a filled column.
"""
if not item.source:
raise ValueError(f"item {item.source_id!r} has no source; the runner sets it")
@@ -241,6 +242,7 @@ class Store:
"created_at": stamp,
}
row |= {name: str(raw.get(name) or "") for name in _RAW_TEXT}
row["country"] = row["country"] or country_of(place)
row |= {name: _int_or_none(raw.get(name)) for name in _RAW_INT}
keep_filled = ("company", "company_key", "place_key", "remote", "description",
@@ -341,6 +343,31 @@ class Store:
AND source_id NOT IN (SELECT value FROM json_each(?))""",
(self.now(), source, subscription_id, json.dumps(list(seen_ids))))
def close_unseen(self, source: str, before: str) -> int:
"""Close every open role of `source` last seen before `before`. For a
source whose fetch is never a complete list, a search, where a role
dropping out of one run's results is not the role closing."""
return self._write(
"""UPDATE roles SET closed_at = ?
WHERE source = ? AND closed_at IS NULL AND last_seen < ?""",
(self.now(), source, before))
def close_subscription(self, subscription_id: int) -> int:
"""Close every open role of one subscription, for a board that is no
longer fetched: nothing would ever close them otherwise."""
return self._write(
"UPDATE roles SET closed_at = ? WHERE subscription_id = ? AND closed_at IS NULL",
(self.now(), subscription_id))
def backfill_country(self) -> int:
"""Fill `country` from `place` on every role that has none, the way
`upsert_role` does for a new one. Returns how many it filled."""
rows = self._rows("SELECT uid, place FROM roles WHERE country = '' AND place != ''")
filled = [(code, r["uid"]) for r in rows if (code := country_of(r["place"]))]
with self.transaction() as conn:
conn.executemany("UPDATE roles SET country = ? WHERE uid = ?", filled)
return len(filled)
# -------------------------------------------------------------- extract
def extract_pending(self) -> int:
@@ -614,6 +641,16 @@ class Store:
"SELECT company_key, COUNT(*) AS n FROM roles "
"WHERE closed_at IS NULL GROUP BY company_key")}
def open_countries_by_subscription(self) -> dict[int, dict[str, int]]:
"""Per subscription id, its open roles counted by `country`."""
rows = self._rows("""SELECT subscription_id, country, COUNT(*) AS n FROM roles
WHERE closed_at IS NULL AND subscription_id IS NOT NULL
GROUP BY subscription_id, country""")
out: dict[int, dict[str, int]] = {}
for r in rows:
out.setdefault(r["subscription_id"], {})[r["country"]] = r["n"]
return out
def company_boards(self) -> dict[str, str]:
"""`company_key -> ats host`, read off each company's own
subscription. `Subscription.company` is the display name it and the