fix(wiki): update_page tags 누락 에러 수정 + refactor(bot): 레거시 NLU/핸들러 800줄 제거
This commit is contained in:
@@ -34,6 +34,7 @@ class WikiPage:
|
||||
content: str = ""
|
||||
updated_at: str = ""
|
||||
description: str = ""
|
||||
tags: list[str] = None
|
||||
|
||||
|
||||
class WikiClient:
|
||||
@@ -93,7 +94,7 @@ class WikiClient:
|
||||
query = """
|
||||
query ($id: Int!) {
|
||||
pages { single(id: $id) {
|
||||
id, path, title, content, updatedAt, description
|
||||
id, path, title, content, updatedAt, description, tags { tag }
|
||||
}}
|
||||
}
|
||||
"""
|
||||
@@ -101,10 +102,11 @@ class WikiClient:
|
||||
p = data["pages"]["single"]
|
||||
if not p:
|
||||
raise RuntimeError(f"페이지 ID {page_id}를 찾을 수 없습니다.")
|
||||
tags = [t["tag"] for t in p.get("tags", [])]
|
||||
return WikiPage(
|
||||
id=p["id"], path=p["path"], title=p["title"],
|
||||
content=p.get("content", ""), updated_at=p.get("updatedAt", ""),
|
||||
description=p.get("description", ""),
|
||||
description=p.get("description", ""), tags=tags,
|
||||
)
|
||||
|
||||
async def find_page(self, path: str) -> Optional[WikiPage]:
|
||||
@@ -156,25 +158,32 @@ class WikiClient:
|
||||
title: str = None, description: str = None, tags: list[str] = None,
|
||||
) -> bool:
|
||||
"""기존 페이지 수정."""
|
||||
query = """
|
||||
mutation ($id: Int!, $content: String!, $title: String,
|
||||
$description: String, $tags: [String!]) {
|
||||
pages { update(
|
||||
id: $id, content: $content, title: $title,
|
||||
description: $description, tags: $tags
|
||||
) {
|
||||
responseResult { succeeded, message }
|
||||
}}
|
||||
}
|
||||
"""
|
||||
variables = {"id": page_id, "content": content}
|
||||
if tags is None:
|
||||
existing = await self.get_page(page_id)
|
||||
tags = existing.tags
|
||||
|
||||
args_def = ["$id: Int!", "$content: String!", "$tags: [String!]"]
|
||||
args_pass = ["id: $id", "content: $content", "tags: $tags"]
|
||||
variables = {"id": page_id, "content": content, "tags": tags}
|
||||
|
||||
if title:
|
||||
args_def.append("$title: String")
|
||||
args_pass.append("title: $title")
|
||||
variables["title"] = title
|
||||
if description:
|
||||
args_def.append("$description: String")
|
||||
args_pass.append("description: $description")
|
||||
variables["description"] = description
|
||||
if tags is not None:
|
||||
variables["tags"] = tags
|
||||
|
||||
query = f"""
|
||||
mutation ({", ".join(args_def)}) {{
|
||||
pages {{ update(
|
||||
{", ".join(args_pass)}
|
||||
) {{
|
||||
responseResult {{ succeeded, message }}
|
||||
}}}}
|
||||
}}
|
||||
"""
|
||||
data = await self._query(query, variables)
|
||||
result = data["pages"]["update"]
|
||||
ok = result["responseResult"]["succeeded"]
|
||||
|
||||
Reference in New Issue
Block a user