Add migration 26, roles.posting_url, kept across pulls and carried on the row and its copies
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
54b56ac370
commit
d168d9eb6c
10 files changed
+76
-19
No files matched your search
@@ -69,6 +69,9 @@ CREATE TABLE IF NOT EXISTS roles (
|
||||
description TEXT NOT NULL DEFAULT '', -- the posting's body text
|
||||
feed_text TEXT NOT NULL DEFAULT '', -- the teaser a feed handed over
|
||||
original_url TEXT NOT NULL DEFAULT '', -- the posting page
|
||||
-- Where a search host's own page leads: Jobindex's "Se jobbet" link, found
|
||||
-- when the posting text is fetched (app.jobs.posting). Never written by an upsert.
|
||||
posting_url TEXT NOT NULL DEFAULT '',
|
||||
published_at TEXT NOT NULL, -- what the source claims, UTC
|
||||
-- What storing postings buys. first_seen is when the app itself first
|
||||
-- stored the role; posted_at (app.models.posted_at) is the earlier of
|
||||
@@ -623,6 +626,9 @@ UPDATE roles SET seniority_model = ''
|
||||
UPDATE roles SET seniority = COALESCE(NULLIF(seniority_model, ''),
|
||||
NULLIF(seniority_stated, ''), seniority_title);
|
||||
"""),
|
||||
# A Python step: it adds the column only where it is missing.
|
||||
(26, "roles.posting_url: where a Jobindex ad's own page leads, found when its text is "
|
||||
"fetched", lambda conn: _add_posting_url(conn)),
|
||||
)
|
||||
|
||||
#: What a file created from `SCHEMA` today is already at.
|
||||
@@ -864,6 +870,14 @@ def _add_fetch_terms(conn: sqlite3.Connection) -> None:
|
||||
conn.execute("ALTER TABLE agents ADD COLUMN fetch_terms TEXT NOT NULL DEFAULT '[]'")
|
||||
|
||||
|
||||
def _add_posting_url(conn: sqlite3.Connection) -> None:
|
||||
"""Migration 26's step: `roles.posting_url`, empty for every role. Runs
|
||||
twice without harm."""
|
||||
columns = {r[1] for r in conn.execute("PRAGMA table_info(roles)")}
|
||||
if "posting_url" not in columns:
|
||||
conn.execute("ALTER TABLE roles ADD COLUMN posting_url TEXT NOT NULL DEFAULT ''")
|
||||
|
||||
|
||||
def _add_all_roles(conn: sqlite3.Connection) -> None:
|
||||
"""Migration 21's step. The column; the tag for every company that is a
|
||||
favourite of any agent, since favourite no longer widens what a pull
|
||||
|
||||
@@ -803,7 +803,7 @@ class Store:
|
||||
"""The open copies of one kept role, oldest first; empty for a copy
|
||||
or a role without any. See `Role.copies`."""
|
||||
return [RoleCopy.from_row(r) for r in self._rows(
|
||||
f"""SELECT uid, {_HOST} AS host, place, original_url, posted_at FROM roles
|
||||
f"""SELECT uid, {_HOST} AS host, place, original_url, posting_url, posted_at FROM roles
|
||||
WHERE dup_of = ? AND closed_at IS NULL AND {_NOT_A_PLACE.format(kept="?")}
|
||||
ORDER BY posted_at, uid""", (uid, uid))]
|
||||
|
||||
@@ -1060,7 +1060,7 @@ class Store:
|
||||
"SELECT roles.uid, roles.company_key, roles.company, roles.title, roles.place, "
|
||||
"roles.country, roles.remote, roles.function, roles.seniority, roles.salary_min, "
|
||||
"roles.salary_max, roles.currency, roles.salary_text, roles.original_url, "
|
||||
"roles.posted_at, roles.read_at, "
|
||||
"roles.posting_url, roles.posted_at, roles.read_at, "
|
||||
"v.vote, v.voted_at, "
|
||||
f"SUBSTR({_EXCERPT_SOURCE}, 1, {_EXCERPT_RAW}) AS excerpt")
|
||||
order = "roles.posted_at DESC, roles.uid"
|
||||
@@ -1629,6 +1629,12 @@ class Store:
|
||||
return None
|
||||
return self.role(uid)
|
||||
|
||||
def set_posting_url(self, uid: str, url: str) -> bool:
|
||||
"""Keep where a search host's own page leads. False for an unknown
|
||||
uid. Only this writes it: `upsert_role` leaves it alone, so a pull
|
||||
keeps it."""
|
||||
return bool(self._write("UPDATE roles SET posting_url = ? WHERE uid = ?", (url, uid)))
|
||||
|
||||
# --------------------------------------------------------------- enrich
|
||||
|
||||
def enrich_waiting(self, top: int, floor: float,
|
||||
|
||||
Reference in new issue
Block a user