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
+8
-2
@@ -809,6 +809,7 @@ class RoleCopy(Model):
|
||||
host: str = ""
|
||||
place: str = ""
|
||||
original_url: str = ""
|
||||
posting_url: str = ""
|
||||
posted_at: str = ""
|
||||
|
||||
|
||||
@@ -865,6 +866,9 @@ class Role(Model):
|
||||
#: The short text the host's list carries, until `description` arrives.
|
||||
teaser: str = ""
|
||||
original_url: str = ""
|
||||
#: Where a Jobindex ad's own page leads, found when the text is fetched
|
||||
#: (`app.jobs.posting`); '' until then and for every other host.
|
||||
posting_url: str = ""
|
||||
published_at: str
|
||||
#: The date this role counts as posted: see `posted_at`. Used for
|
||||
#: `recency` and the feed's newest order; `first_seen` stays what it
|
||||
@@ -974,8 +978,9 @@ class RoleRow(Model):
|
||||
there is one, else the description's opening, cut to `EXCERPT_LIMIT`
|
||||
characters. The pay fields are what the row's badge reads: the three
|
||||
normalised columns, the line the board stated, and `salary_state`,
|
||||
derived as on `Role`. `original_url` is one short string, kept so the
|
||||
`o` key opens a selected row's posting without opening the reader.
|
||||
derived as on `Role`. `original_url` and `posting_url` are short strings,
|
||||
kept so the `o` key opens a selected row's posting without opening the
|
||||
reader.
|
||||
`seniority` is the title's level until extract reads the posting, ''
|
||||
when neither says. `copies` counts the open copies the feed hides behind
|
||||
this row."""
|
||||
@@ -994,6 +999,7 @@ class RoleRow(Model):
|
||||
currency: str = ""
|
||||
salary_text: str = ""
|
||||
original_url: str = ""
|
||||
posting_url: str = ""
|
||||
posted_at: str = ""
|
||||
score: float | None = None
|
||||
gated_reason: str = ""
|
||||
|
||||
@@ -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