diff --git a/app/models.py b/app/models.py index 8c32203..d01b385 100644 --- a/app/models.py +++ b/app/models.py @@ -264,6 +264,14 @@ class Role(Model): raw: JsonDict = {} extracted_at: str | None = None created_at: str + #: None unjudged, else -1 pass, 0 neutral, 1 like. + vote: Literal[-1, 0, 1] | None = None + voted_at: str | None = None + summary: str = "" + summarised_at: str | None = None + #: The posting page as plain text, for a role whose description is a teaser. + article_text: str = "" + article_at: str | None = None class ExtractResult(ModelTaskResult): diff --git a/app/storage/schema.py b/app/storage/schema.py index 45fedaf..d4191f3 100644 --- a/app/storage/schema.py +++ b/app/storage/schema.py @@ -67,6 +67,17 @@ CREATE TABLE IF NOT EXISTS roles ( -- Replies from extract that left this role unanswered. At GIVE_UP_AFTER it -- is no longer offered. A column, not raw, because every upsert rewrites raw. extract_tries INTEGER NOT NULL DEFAULT 0, + -- The owner's judgement of the role: NULL unjudged, else -1 pass, 0 + -- neutral, 1 like. It moves the rank at read time and never hides a role. + vote INTEGER CHECK (vote IN (-1, 0, 1)), + voted_at TEXT, + -- About 60 words from summarise, and when it wrote them. + summary TEXT NOT NULL DEFAULT '', + summarised_at TEXT, + -- The posting's own page as plain text, fetched on demand for a role + -- whose description is only a teaser. + article_text TEXT NOT NULL DEFAULT '', + article_at TEXT, created_at TEXT NOT NULL ); @@ -225,6 +236,14 @@ CREATE TABLE vectors ( ); ALTER TABLE agents ADD COLUMN intent_key TEXT NOT NULL DEFAULT ''; ALTER TABLE agents ADD COLUMN intent_vec BLOB; +"""), + (4, "roles.vote, roles.summary and roles.article_text, for the phone UI", """ +ALTER TABLE roles ADD COLUMN vote INTEGER CHECK (vote IN (-1, 0, 1)); +ALTER TABLE roles ADD COLUMN voted_at TEXT; +ALTER TABLE roles ADD COLUMN summary TEXT NOT NULL DEFAULT ''; +ALTER TABLE roles ADD COLUMN summarised_at TEXT; +ALTER TABLE roles ADD COLUMN article_text TEXT NOT NULL DEFAULT ''; +ALTER TABLE roles ADD COLUMN article_at TEXT; """), ) diff --git a/tests/test_storage.py b/tests/test_storage.py index 1a5f4cb..bcd6894 100644 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -85,7 +85,8 @@ def test_a_v1_file_migrates_to_the_shape_a_new_file_has(tmp_path: Path) -> None: Store(fresh) Store(old) with sqlite3.connect(old) as conn: - for column in ("permit", "languages", "extract_tries"): + for column in ("permit", "languages", "extract_tries", "vote", "voted_at", + "summary", "summarised_at", "article_text", "article_at"): conn.execute(f"ALTER TABLE roles DROP COLUMN {column}") for column in ("intent_key", "intent_vec"): conn.execute(f"ALTER TABLE agents DROP COLUMN {column}")