fix(api): KB 首席架構師審查修復 (I1 tags filter + I2 type annotation)
Some checks failed
E2E Health Check / e2e-health (push) Successful in 16s
CD Pipeline / build-and-deploy (push) Has been cancelled

- I1: Repository list_entries 實作 tags JSONB @> 篩選 (之前聲明未實作)
- I2: ORM tags 型別從 list[dict[str, Any]] 修正為 list[str]

首席架構師審查: 87/100
C1 時區(UTC→Taipei) 為既有系統性問題,另開 task 統一遷移

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
OG T
2026-04-02 09:04:41 +08:00
parent e17248fd10
commit 48a0bc66f7
2 changed files with 7 additions and 2 deletions

View File

@@ -494,11 +494,11 @@ class KnowledgeEntryRecord(Base):
nullable=False,
comment="分類樹節點 (基礎設施/應用層/AI系統/安全合規)",
)
tags: Mapped[list[dict[str, Any]]] = mapped_column(
tags: Mapped[list[str]] = mapped_column(
JSON,
default=list,
nullable=False,
comment="標籤列表 (JSONB)",
comment="標籤列表 (JSONB string array)",
)
# Source & Status

View File

@@ -115,6 +115,11 @@ class KnowledgeDBRepository:
if status:
query = query.where(KnowledgeEntryRecord.status == status)
count_query = count_query.where(KnowledgeEntryRecord.status == status)
if tags:
for tag in tags:
tag_filter = KnowledgeEntryRecord.tags.op('@>')(f'["{tag}"]')
query = query.where(tag_filter)
count_query = count_query.where(tag_filter)
if q:
like_q = f"%{q}%"
filter_cond = or_(