Split the All tag into two company overrides: All countries and All roles (WP L)
Fetching has two filters, and a company now overrides each on its own.
All countries (companies.all_countries) is the old All roles tag: its big
boards are read with the agents' wide reach. All roles (companies.all_roles,
new meaning) drops the agents' fetch terms and any later role filter.
- Migration 24 copies the old tag to all_countries and keeps all_roles for
those companies, and moves a board's {"terms": false} to its company.
- The runner no longer reads {"terms": false}; the plan leaves the terms out
for a company set to All roles.
- POST /api/companies/{key}/all-countries and /all-roles, each queueing a
pull when turned on; CompanyOut carries both.
- Two toggles replace All on the Companies row, the reader and the Roles
strip; the reach line states countries and role types in plain words;
the filter select gets both options.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
795ca3628c
commit
e52857dea5
23 files changed
+602
-215
No files matched your search
+50
-4
@@ -195,9 +195,11 @@ CREATE TABLE IF NOT EXISTS role_tags (
|
||||
-- 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. all_roles 1 reads every board of the company with
|
||||
-- the agents' wide reach, Europe today (app/jobs/reach.py); global, since
|
||||
-- fetching is shared.
|
||||
-- '' when nobody has to. The two fetch overrides, global since fetching is
|
||||
-- shared (app/jobs/reach.py): all_countries 1 reads every big board of the
|
||||
-- company with the agents' wide reach, Europe today, rather than their
|
||||
-- places; all_roles 1 reads them with no role-type narrowing, no fetch terms
|
||||
-- today. Until migration 24, all_roles meant what all_countries means now.
|
||||
CREATE TABLE IF NOT EXISTS companies (
|
||||
key TEXT PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
@@ -222,7 +224,8 @@ CREATE TABLE IF NOT EXISTS companies (
|
||||
last_funding_currency TEXT NOT NULL DEFAULT '',
|
||||
facts_source TEXT NOT NULL DEFAULT '',
|
||||
facts_at TEXT NOT NULL DEFAULT '',
|
||||
all_roles INTEGER NOT NULL DEFAULT 0
|
||||
all_roles INTEGER NOT NULL DEFAULT 0,
|
||||
all_countries INTEGER NOT NULL DEFAULT 0
|
||||
);
|
||||
|
||||
-- Every folded spelling of a company (models.company_fold): orsted is Ørsted
|
||||
@@ -604,6 +607,10 @@ ALTER TABLE companies ADD COLUMN hand_reason TEXT NOT NULL DEFAULT '';
|
||||
# A Python step: it adds the column only where it is missing.
|
||||
(23, "agents.fetch_terms: words that narrow what big boards read with the wide reach "
|
||||
"send", lambda conn: _add_fetch_terms(conn)),
|
||||
# A Python step: params is JSON and the company is found by company_key.
|
||||
(24, "companies.all_countries takes over the All roles tag, and companies.all_roles "
|
||||
"means no role narrowing; a board's {\"terms\": false} becomes its company's "
|
||||
"all_roles", lambda conn: _split_all_roles(conn)),
|
||||
)
|
||||
|
||||
#: What a file created from `SCHEMA` today is already at.
|
||||
@@ -879,6 +886,45 @@ def _add_all_roles(conn: sqlite3.Connection) -> None:
|
||||
"to tag; it reads the agents' reach now", target, key)
|
||||
|
||||
|
||||
def _split_all_roles(conn: sqlite3.Connection) -> None:
|
||||
"""Migration 24's step. Fetching has two filters, countries and role
|
||||
types, and each gets its own company override. `all_countries` is the
|
||||
old All roles tag, the wide reach, copied from `all_roles` when the
|
||||
column is added. `all_roles` keeps its column and now means no role-type
|
||||
narrowing: a company that had the tag keeps it too, since the tag was
|
||||
given to the favourites whose every role the owner wanted. A board whose
|
||||
`params` hold `{"terms": false}` gives its company `all_roles`, and the
|
||||
param goes. Runs twice without harm: the copy happens only with the new
|
||||
column."""
|
||||
columns = {r[1] for r in conn.execute("PRAGMA table_info(companies)")}
|
||||
if "all_countries" not in columns:
|
||||
conn.execute("ALTER TABLE companies ADD COLUMN all_countries INTEGER NOT NULL DEFAULT 0")
|
||||
copied = conn.execute("UPDATE companies SET all_countries=1 WHERE all_roles=1").rowcount
|
||||
log.info("migration 24: %d companies tagged All roles are All countries and All roles",
|
||||
copied)
|
||||
moved = 0
|
||||
for sub_id, target, company, label, raw in conn.execute(
|
||||
"SELECT id, target, company, label, params FROM subscriptions "
|
||||
"WHERE source = 'ats'").fetchall():
|
||||
try:
|
||||
params = json.loads(raw or "{}")
|
||||
except ValueError:
|
||||
continue
|
||||
if not isinstance(params, dict) or "terms" not in params:
|
||||
continue
|
||||
off = params.pop("terms") is False
|
||||
conn.execute("UPDATE subscriptions SET params=? WHERE id=?", (json.dumps(params), sub_id))
|
||||
key = company_key(company or label)
|
||||
if not off:
|
||||
continue
|
||||
if conn.execute("UPDATE companies SET all_roles=1 WHERE key=?", (key,)).rowcount:
|
||||
moved += 1
|
||||
else:
|
||||
log.warning("migration 24: %s read without terms, but %r has no company row "
|
||||
"to mark All roles; it takes the agents' terms now", target, key)
|
||||
log.info("migration 24: %d boards' {\"terms\": false} became All roles", moved)
|
||||
|
||||
|
||||
_V22_COLUMNS = ("seniority_host", "employment_host", "remote_host", "country_host", "employment")
|
||||
|
||||
_V22 = """
|
||||
|
||||
+20
-10
@@ -125,7 +125,7 @@ _EXCERPT_RAW = 240
|
||||
_COMPANY_FIELDS = ("name", "domain", "status", "careers_url", "notes", "ats", "country", "city",
|
||||
"ats_slug", "watch", "careers_opened_at", "hand_reason", "sector", "stage",
|
||||
"size_band", "founded", "last_funding", "last_funding_currency",
|
||||
"facts_source", "facts_at", "all_roles")
|
||||
"facts_source", "facts_at", "all_roles", "all_countries")
|
||||
|
||||
#: 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
|
||||
@@ -1938,9 +1938,16 @@ class Store:
|
||||
self._alias(conn, key, fields["name"])
|
||||
return self._company(key)
|
||||
|
||||
def set_all_countries(self, key: str, on: bool) -> Company:
|
||||
"""Switch a company's All countries override: its big boards are read
|
||||
with the agents' wide reach, Europe today, rather than their places,
|
||||
from the next pull (`app/jobs/reach.py`). Global, not per agent.
|
||||
Raises KeyError for an unknown company."""
|
||||
return self.update_company(key, all_countries=int(bool(on)))
|
||||
|
||||
def set_all_roles(self, key: str, on: bool) -> Company:
|
||||
"""Tag a company All roles, or untag it: its boards are read with the
|
||||
agents' wide reach, Europe today, from the next pull
|
||||
"""Switch a company's All roles override: its boards are read with no
|
||||
role-type narrowing, no fetch terms today, from the next pull
|
||||
(`app/jobs/reach.py`). Global, not per agent. Raises KeyError for an
|
||||
unknown company."""
|
||||
return self.update_company(key, all_roles=int(bool(on)))
|
||||
@@ -2001,10 +2008,11 @@ class Store:
|
||||
def merge_companies(self, keep: str, other: str) -> Company:
|
||||
"""Fold company `other` into `keep`, in one transaction: its roles and
|
||||
subscriptions move to `keep`, each agent's stance moves unless the
|
||||
agent has one on `keep` already, an All roles tag carries over, its
|
||||
aliases and its name become aliases of `keep`, and its row goes. Copies are not recomputed
|
||||
(`rebuild_dupes`). Raises KeyError for an unknown company and
|
||||
ValueError for merging one into itself."""
|
||||
agent has one on `keep` already, the All countries and All roles
|
||||
overrides carry over, its aliases and its name become aliases of
|
||||
`keep`, and its row goes. Copies are not recomputed (`rebuild_dupes`).
|
||||
Raises KeyError for an unknown company and ValueError for merging one
|
||||
into itself."""
|
||||
if keep == other:
|
||||
raise ValueError("a company cannot be merged into itself")
|
||||
with self.transaction() as conn:
|
||||
@@ -2025,9 +2033,11 @@ class Store:
|
||||
(keep, other))
|
||||
conn.execute("DELETE FROM company_aliases WHERE company_key=?", (other,))
|
||||
self._alias(conn, keep, rows[other])
|
||||
conn.execute("UPDATE companies SET all_roles = MAX(all_roles, "
|
||||
"(SELECT all_roles FROM companies WHERE key=?)) WHERE key=?",
|
||||
(other, keep))
|
||||
conn.execute("UPDATE companies SET "
|
||||
"all_roles = MAX(all_roles, (SELECT all_roles FROM companies WHERE key=?)), "
|
||||
"all_countries = MAX(all_countries, "
|
||||
"(SELECT all_countries FROM companies WHERE key=?)) WHERE key=?",
|
||||
(other, other, keep))
|
||||
conn.execute("DELETE FROM companies WHERE key=?", (other,))
|
||||
return self._company(keep)
|
||||
|
||||
|
||||
Reference in new issue
Block a user