MVP 0.94
This commit is contained in:
1 parent
f17b3083e8
commit
4f37991ad1
48 files changed
+4919
-540
No files matched your search
@@ -89,7 +89,19 @@ def _owned(conn, table: str, record_id: str, profile_id: str) -> dict | None:
|
||||
def _decode_draft(conn, row: dict | None) -> dict | None:
|
||||
if not row:
|
||||
return None
|
||||
return _attach_sources(conn, "journal_draft_source_refs", "draft_id", row["id"], row)
|
||||
payload = _attach_sources(conn, "journal_draft_source_refs", "draft_id", row["id"], row)
|
||||
raw = payload.get("generation_snapshot") or "{}"
|
||||
try:
|
||||
snapshot = json.loads(raw) if isinstance(raw, str) else (raw or {})
|
||||
except json.JSONDecodeError:
|
||||
snapshot = {}
|
||||
if not isinstance(snapshot, dict):
|
||||
snapshot = {}
|
||||
payload["generation_snapshot"] = snapshot
|
||||
from journal_generation_policy import snapshot_summary
|
||||
|
||||
payload["generation_summary"] = snapshot_summary(snapshot)
|
||||
return payload
|
||||
|
||||
|
||||
def _decode_version(conn, row: dict | None) -> dict | None:
|
||||
@@ -219,6 +231,7 @@ def insert_draft(
|
||||
body: str,
|
||||
source_conversation_ids: list[str],
|
||||
source_message_ids: list[str],
|
||||
generation_snapshot: dict | None = None,
|
||||
) -> dict:
|
||||
get_day(profile_id, journal_day_id)
|
||||
draft_id = str(uuid.uuid4())
|
||||
@@ -236,8 +249,8 @@ def insert_draft(
|
||||
"""
|
||||
INSERT INTO journal_drafts
|
||||
(id, profile_id, journal_day_id, title, body,
|
||||
source_conversation_ids, source_message_ids, as_of)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
||||
source_conversation_ids, source_message_ids, as_of, generation_snapshot)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""",
|
||||
(
|
||||
draft_id,
|
||||
@@ -248,6 +261,7 @@ def insert_draft(
|
||||
"[]",
|
||||
"[]",
|
||||
as_of,
|
||||
json.dumps(generation_snapshot or {}, ensure_ascii=False),
|
||||
),
|
||||
)
|
||||
_insert_source_refs(
|
||||
|
||||
Reference in new issue
Block a user