统计创建浏览器、系统时限制名称长度

This commit is contained in:
GoEdgeLab
2021-06-29 19:38:14 +08:00
parent 0e87f2bcba
commit bb1739d042
5 changed files with 37 additions and 6 deletions

View File

@@ -104,6 +104,11 @@ func (this *ClientBrowserDAO) FindBrowserIdWithNameCacheable(tx *dbs.Tx, browser
// CreateBrowser 创建浏览器
func (this *ClientBrowserDAO) CreateBrowser(tx *dbs.Tx, browserName string) (int64, error) {
var maxlength = 50
if len(browserName) > maxlength {
browserName = browserName[:50]
}
SharedCacheLocker.Lock()
defer SharedCacheLocker.Unlock()

View File

@@ -104,6 +104,11 @@ func (this *ClientSystemDAO) FindSystemIdWithNameCacheable(tx *dbs.Tx, systemNam
// CreateSystem 创建浏览器
func (this *ClientSystemDAO) CreateSystem(tx *dbs.Tx, systemName string) (int64, error) {
var maxlength = 50
if len(systemName) > maxlength {
systemName = systemName[:50]
}
SharedCacheLocker.Lock()
defer SharedCacheLocker.Unlock()

View File

@@ -23,10 +23,16 @@ func (this *NodeClusterMetricItemService) EnableNodeClusterMetricItem(ctx contex
}
var tx = this.NullTx()
exists, err := models.SharedNodeClusterMetricItemDAO.ExistsClusterItem(tx, req.NodeClusterId, req.MetricItemId)
if err != nil {
return nil, err
}
if !exists {
err = models.SharedNodeClusterMetricItemDAO.EnableClusterItem(tx, req.NodeClusterId, req.MetricItemId)
if err != nil {
return nil, err
}
}
return this.Success()
}
@@ -53,7 +59,7 @@ func (this *NodeClusterMetricItemService) FindAllNodeClusterMetricItems(ctx cont
}
var tx = this.NullTx()
clusterItems, err := models.SharedNodeClusterMetricItemDAO.FindAllClusterItems(tx, req.NodeClusterId)
clusterItems, err := models.SharedNodeClusterMetricItemDAO.FindAllClusterItems(tx, req.NodeClusterId, req.Category)
if err != nil {
return nil, err
}
@@ -79,3 +85,18 @@ func (this *NodeClusterMetricItemService) FindAllNodeClusterMetricItems(ctx cont
}
return &pb.FindAllNodeClusterMetricItemsResponse{MetricItems: pbItems}, nil
}
// ExistsNodeClusterMetricItem 检查是否已添加某个指标
func (this *NodeClusterMetricItemService) ExistsNodeClusterMetricItem(ctx context.Context, req *pb.ExistsNodeClusterMetricItemRequest) (*pb.RPCExists, error) {
_, err := this.ValidateAdmin(ctx, 0)
if err != nil {
return nil, err
}
var tx = this.NullTx()
b, err := models.SharedNodeClusterMetricItemDAO.ExistsClusterItem(tx, req.NodeClusterId, req.MetricItemId)
if err != nil {
return nil, err
}
return this.Exists(b)
}

View File

@@ -7,12 +7,12 @@ import (
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
)
// 操作系统统计
// ServerClientBrowserMonthlyStatService 操作系统统计
type ServerClientBrowserMonthlyStatService struct {
BaseService
}
// 查找前N个操作系统
// FindTopServerClientBrowserMonthlyStats 查找前N个操作系统
func (this *ServerClientBrowserMonthlyStatService) FindTopServerClientBrowserMonthlyStats(ctx context.Context, req *pb.FindTopServerClientBrowserMonthlyStatsRequest) (*pb.FindTopServerClientBrowserMonthlyStatsResponse, error) {
_, userId, err := this.ValidateAdminAndUser(ctx, 0, 0)
if err != nil {

View File

@@ -7,12 +7,12 @@ import (
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
)
// 操作系统统计
// ServerClientSystemMonthlyStatService 操作系统统计
type ServerClientSystemMonthlyStatService struct {
BaseService
}
// 查找前N个操作系统
// FindTopServerClientSystemMonthlyStats 查找前N个操作系统
func (this *ServerClientSystemMonthlyStatService) FindTopServerClientSystemMonthlyStats(ctx context.Context, req *pb.FindTopServerClientSystemMonthlyStatsRequest) (*pb.FindTopServerClientSystemMonthlyStatsResponse, error) {
_, userId, err := this.ValidateAdminAndUser(ctx, 0, 0)
if err != nil {