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

+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
-- name that host knows the company by (the acme of acme.teamtailor.com),
-- '' 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),
-- '' when nobody has to, and checked_at when one last did, '' for never.
-- '' when nobody has to.
CREATE TABLE IF NOT EXISTS companies (
key TEXT PRIMARY KEY,
name TEXT NOT NULL,
@@ -122,8 +125,9 @@ CREATE TABLE IF NOT EXISTS companies (
country TEXT NOT NULL DEFAULT '',
city TEXT NOT NULL DEFAULT '',
ats_slug TEXT NOT NULL DEFAULT '',
hand_reason TEXT NOT NULL DEFAULT '',
checked_at TEXT NOT NULL DEFAULT ''
watch INTEGER CHECK (watch IN (0, 1)),
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
@@ -428,10 +432,19 @@ ALTER TABLE agents DROP COLUMN intent_key;
ALTER TABLE agents DROP COLUMN intent_vec;
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 "
"with a reason and a date last looked at", """
# The Watchlist's own rating, global and apart from an agent's affinity:
# 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 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
_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.
_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
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
to. `q` is matched word by word against `title`; a role must match
every word. `function` and `remote` match a gate column exactly.
`days` keeps only roles posted within that many days of now. `pay`
(a key of `PAY`) filters on `salary_state`.
to. `q` is matched word by word against `title` and `company`; a
role must match every word in one or the other. `function` and
`remote` match a gate column exactly. `days` keeps only roles posted
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
row carries that agent's `vote` and `voted_at`; `judged` (a key of
@@ -653,8 +654,8 @@ class Store:
where.append("posted_at >= ?")
params.append(_iso(self.clock() - timedelta(days=days)))
for word in (q or "").split():
where.append("title LIKE ? ESCAPE '\\'")
params.append(_like(word))
where.append("(title LIKE ? ESCAPE '\\' OR company LIKE ? ESCAPE '\\')")
params += [_like(word)] * 2
if judged:
if judged not in JUDGED:
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 = "",
status: str = "researching", careers_url: str = "",
notes: str = "", ats: str = "", country: str = "",
city: str = "", ats_slug: str = "", hand_reason: str = "",
checked_at: str = "") -> Company:
city: str = "", ats_slug: str = "",
hand_reason: str = "") -> Company:
"""Raises ValueError on a key already taken or a `hand_reason` outside
`HAND_REASONS`."""
name = name.strip()
@@ -1176,8 +1177,7 @@ class Store:
self._insert_company(conn, key, name, {
"domain": domain, "status": status, "careers_url": careers_url,
"notes": notes, "ats": ats, "country": country, "city": city,
"ats_slug": ats_slug, "hand_reason": hand_reason,
"checked_at": checked_at})
"ats_slug": ats_slug, "hand_reason": hand_reason})
except sqlite3.IntegrityError as exc:
raise ValueError(f"company {key!r} already exists") from exc
return self._company(key)