fix(workspace): tags list inclut tous les tags utilisateur (count 0 workspace) pour menu contextuel
This commit is contained in:
@@ -1907,7 +1907,7 @@ async def list_all_tags_global(request: Request):
|
||||
|
||||
@router.get("/api/local-workspace/tags")
|
||||
async def list_tags(request: Request):
|
||||
"""List tags used in the active workspace (current user's tags only)."""
|
||||
"""List ALL user tags with counts scoped to the active workspace."""
|
||||
ws = _get_active_workspace(request, user_id=_get_user_id(request))
|
||||
ws_id = ws["id"] if ws else None
|
||||
uid = _get_user_id(request)
|
||||
@@ -1915,10 +1915,10 @@ async def list_tags(request: Request):
|
||||
return {"tags": []}
|
||||
with get_conn() as conn:
|
||||
rows = conn.execute(
|
||||
"SELECT DISTINCT t.id, t.name, t.color, COUNT(pt.page_id) as count "
|
||||
"SELECT t.id, t.name, t.color, COUNT(pt.page_id) as count "
|
||||
"FROM tags t "
|
||||
"JOIN page_tags pt ON pt.tag_id = t.id "
|
||||
"JOIN pages p ON p.id = pt.page_id AND p.workspace_id = ? "
|
||||
"LEFT JOIN page_tags pt ON pt.tag_id = t.id "
|
||||
"LEFT JOIN pages p ON p.id = pt.page_id AND p.workspace_id = ? "
|
||||
"WHERE t.user_id = ? GROUP BY t.id ORDER BY t.name",
|
||||
(ws_id, uid),
|
||||
).fetchall()
|
||||
|
||||
Reference in New Issue
Block a user