feat(cache): mirror §22.4c review fields into cached_rfcs

This commit is contained in:
Ben Stull
2026-06-03 22:42:05 -07:00
parent 2d9022b19e
commit 8f21dc5f9c
2 changed files with 34 additions and 2 deletions
+10 -2
View File
@@ -87,8 +87,10 @@ def _upsert_cached_rfc(entry: entry_mod.Entry, body_sha: str) -> None:
INSERT INTO cached_rfcs
(slug, title, state, rfc_id, repo, proposed_by, proposed_at,
graduated_at, graduated_by, owners_json, arbiters_json, tags_json,
models_json, funder_login, body, body_sha, last_entry_commit_at, updated_at)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, datetime('now'), datetime('now'))
models_json, funder_login, body, body_sha,
unreviewed, reviewed_at, reviewed_by,
last_entry_commit_at, updated_at)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, datetime('now'), datetime('now'))
ON CONFLICT(slug) DO UPDATE SET
title = excluded.title,
state = excluded.state,
@@ -105,6 +107,9 @@ def _upsert_cached_rfc(entry: entry_mod.Entry, body_sha: str) -> None:
funder_login = excluded.funder_login,
body = excluded.body,
body_sha = excluded.body_sha,
unreviewed = excluded.unreviewed,
reviewed_at = excluded.reviewed_at,
reviewed_by = excluded.reviewed_by,
last_entry_commit_at = datetime('now'),
updated_at = datetime('now')
""",
@@ -125,6 +130,9 @@ def _upsert_cached_rfc(entry: entry_mod.Entry, body_sha: str) -> None:
funder_login,
entry.body,
body_sha,
1 if entry.unreviewed else 0,
entry.reviewed_at,
entry.reviewed_by,
),
)
+24
View File
@@ -0,0 +1,24 @@
"""§22.4c — _upsert_cached_rfc mirrors the review fields into cached_rfcs."""
from __future__ import annotations
from fastapi.testclient import TestClient
from test_propose_vertical import app_with_fake_gitea, tmp_env # noqa: F401
def test_upsert_writes_review_fields(app_with_fake_gitea):
from app import cache, db, entry as entry_mod
app, _ = app_with_fake_gitea
with TestClient(app):
e = entry_mod.Entry(
slug="rev", title="Rev", state="active",
unreviewed=True, reviewed_at="2026-06-03", reviewed_by="ben",
)
cache._upsert_cached_rfc(e, body_sha="sha-rev")
row = db.conn().execute(
"SELECT unreviewed, reviewed_at, reviewed_by FROM cached_rfcs WHERE slug = 'rev'"
).fetchone()
assert row["unreviewed"] == 1
assert row["reviewed_at"] == "2026-06-03"
assert row["reviewed_by"] == "ben"