|
@@ -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
|
|
|
|