4 Commits f67bbfc182 ... 0b3001c3a5

Author SHA1 Message Date
  ‘suhuihui’ 0b3001c3a5 Merge branch '1.1.3-suhh' into 1.1.3-master 3 months ago
  zhouyuexiang b2f4e62fd0 知识库类别统计返回count 3 months ago
  CzRger 9c14bd9295 Merge branch '1.1.3-master_web' of http://8.130.72.63:18081/shenzhen/tjdify into 1.1.3-master 3 months ago
  CzRger 5c9740687b 饼图 3 months ago
2 changed files with 3 additions and 7 deletions
  1. 1 6
      api/services/dataset_service.py
  2. 2 1
      web/app/(commonLayout)/datasets/Statistic.tsx

+ 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
 

+ 2 - 1
web/app/(commonLayout)/datasets/Statistic.tsx

@@ -53,12 +53,13 @@ const Statistic = () => {
         type: 'pie',
         radius: ['26%', '50%'],
         data: typeData.map((v: any) => {
-          v.value = v.value || 100
+          v.value = v.count || 0
           v.name = v.type
           return v
         }),
         label: {
           formatter: '{b} {d}%',
+          overflow: 'break',
         },
         emphasis: {
           disabled: true,