fix(km): restore knowledge base readback

This commit is contained in:
Your Name
2026-07-03 00:03:35 +08:00
parent 33f6009b56
commit 0dca32a7c1
4 changed files with 254 additions and 43 deletions

View File

@@ -252,13 +252,18 @@ class KnowledgeService:
result = await db.execute(
sa_text(
"SELECT id FROM knowledge_entries "
"WHERE entry_type = 'anti_pattern' "
"WHERE LOWER(CAST(entry_type AS TEXT)) = :entry_type "
"AND symptoms_hash = :hash "
"AND created_at >= :cutoff "
"AND status != 'ARCHIVED' "
"AND LOWER(CAST(status AS TEXT)) != :archived "
"ORDER BY created_at DESC LIMIT 5"
),
{"hash": symptoms_hash, "cutoff": cutoff},
{
"entry_type": EntryType.ANTI_PATTERN.value,
"hash": symptoms_hash,
"cutoff": cutoff,
"archived": EntryStatus.ARCHIVED.value,
},
)
entry_ids = [row.id for row in result.fetchall()]