feat: recover evolving threads from freeform notes
This commit is contained in:
@@ -604,19 +604,38 @@ class Database:
|
||||
continue
|
||||
seen.add(idea_id)
|
||||
affected.append(idea_id)
|
||||
connection.execute(
|
||||
"""
|
||||
INSERT OR IGNORE INTO idea_fragments (
|
||||
idea_id, fragment_id, relevance, created_at
|
||||
) VALUES (?, ?, ?, ?)
|
||||
""",
|
||||
(
|
||||
idea_id,
|
||||
fragment_id,
|
||||
assessment.get("relevance", 1),
|
||||
now,
|
||||
),
|
||||
)
|
||||
evidence_fragment_ids: list[str] = []
|
||||
for evidence_fragment_id in [
|
||||
fragment_id,
|
||||
*assessment.get("supporting_fragment_ids", []),
|
||||
]:
|
||||
if evidence_fragment_id in evidence_fragment_ids:
|
||||
continue
|
||||
evidence_exists = connection.execute(
|
||||
"""
|
||||
SELECT 1 FROM fragments
|
||||
WHERE id = ? AND user_id = ?
|
||||
""",
|
||||
(evidence_fragment_id, user_id),
|
||||
).fetchone()
|
||||
if not evidence_exists:
|
||||
raise ValueError(
|
||||
"supporting fragment not found for user"
|
||||
)
|
||||
evidence_fragment_ids.append(evidence_fragment_id)
|
||||
connection.execute(
|
||||
"""
|
||||
INSERT OR IGNORE INTO idea_fragments (
|
||||
idea_id, fragment_id, relevance, created_at
|
||||
) VALUES (?, ?, ?, ?)
|
||||
""",
|
||||
(
|
||||
idea_id,
|
||||
evidence_fragment_id,
|
||||
assessment.get("relevance", 1),
|
||||
now,
|
||||
),
|
||||
)
|
||||
version_state = connection.execute(
|
||||
"""
|
||||
SELECT maturity_override FROM ideas
|
||||
|
||||
Reference in New Issue
Block a user