增加历史数据

This commit is contained in:
qiwang 2023-10-18 19:26:57 +08:00
parent a429d16879
commit 83106469e8
2 changed files with 24 additions and 1 deletions

View File

@ -141,6 +141,18 @@ func ListCluster(c *gin.Context) {
}
}
var clusterHistory Cluster
rows, _ := DB.Query("SELECT t.cluster_name as ClusterName, t.domain_id as DomainId ,t.domain_name as DomainName, t.node as NodeNum , t.version as Version FROM cluster_resource_history t")
for rows.Next() {
err := rows.Scan(&clusterHistory.ClusterName, &clusterHistory.DomainId, &clusterHistory.DomainName, &clusterHistory.NodeNum, &clusterHistory.Version)
if err != nil {
glog.Errorf("query failed!,error %v", err)
Response(c, http.StatusBadRequest, "query failed!", err)
return
}
clusterList = append(clusterList, clusterHistory)
}
pageNum := c.Query("pageNum")
pageSize := c.Query("pageSize")
// 分页

View File

@ -364,7 +364,18 @@ func ResourceCount(c *gin.Context) {
glog.Info("failed to retrieve cluster(%s). error: %v", clusters, err)
Response(c, http.StatusBadRequest, "failed to retrieve cluster", err)
}
overview.Cluster = len(clusters.Items)
rows, _ = DB.Query("select count(*) as historyClusterCount from cluster_resource_history")
var historyClusterCount int
for rows.Next() {
err := rows.Scan(&historyClusterCount)
if err != nil {
glog.Errorf("query failed!,error %v", err)
Response(c, http.StatusBadRequest, "query failed!", err)
return
}
}
overview.Cluster = len(clusters.Items) + historyClusterCount
//容器数量
overview.Pod = countPod()
//纳管算力总计