Browse Source

知识库类别统计返回count

zhouyuexiang 1 month ago
parent
commit
b2f4e62fd0
1 changed files with 1 additions and 6 deletions
  1. 1 6
      api/services/dataset_service.py

+ 1 - 6
api/services/dataset_service.py

@@ -253,16 +253,11 @@ class DatasetService:
              WHERE t.type = 'knowledge_category'
          """
         params = {}
-
         if tenant_id:
             sql += " AND d.tenant_id = :tenant_id"
             params["tenant_id"] = tenant_id
-
         sql += " GROUP BY t.name, t.id"
-
-        # 注意这里要用 text(sql)
         result = db.session.execute(text(sql), params).fetchall()
-
         total = sum(row.count for row in result)
         if total == 0:
             return []
@@ -271,7 +266,7 @@ class DatasetService:
         stats = []
         for row in result:
             percentage = (row.count / total) * 100
-            stats.append({"type": row.name, "percentage": round(percentage, 2)})
+            stats.append({"type": row.name,"count": row.count, "percentage": round(percentage, 2)})
 
         return stats