Skip to content

Commit

Permalink
Merge pull request koderover#1001 from dyliu/fix_devops_data_issue_ch…
Browse files Browse the repository at this point in the history
…erry_pick_to_1.9.0

cherry pick to 1.9.0
  • Loading branch information
flyer103 authored Jan 27, 2022
2 parents 089bf03 + 8c29db0 commit fe1722f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,6 @@ func (c *DeliveryArtifactColl) EnsureIndex(ctx context.Context) error {
return err
}

func (c *DeliveryArtifactColl) Count() (int64, error) {
query := bson.M{}

ctx := context.Background()
count, err := c.Collection.CountDocuments(ctx, query)
if err != nil {
return 0, err
}

return count, nil
}

func (c *DeliveryArtifactColl) List(args *DeliveryArtifactArgs) ([]*models.DeliveryArtifact, int, error) {
if args == nil {
return nil, 0, errors.New("nil delivery_artifact args")
Expand Down
4 changes: 2 additions & 2 deletions pkg/microservice/aslan/core/stat/service/deploy_stat.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ type deployHigherStat struct {
}

func GetDeployTopFiveHigherMeasure(startDate, endDate int64, productNames []string, log *zap.SugaredLogger) ([]*deployHigherStat, error) {
deployStats, err := mongodb.NewDeployStatColl().ListDeployStat(&models.DeployStatOption{StartDate: startDate, EndDate: endDate, IsAsc: true, ProductNames: productNames})
deployStats, err := mongodb.NewDeployStatColl().ListDeployStat(&models.DeployStatOption{StartDate: startDate, EndDate: endDate, IsAsc: true, ProductNames: productNames, Limit: 5, IsMaxDeploy: true})
if err != nil {
log.Errorf("ListDeployStat err:%v", err)
return nil, fmt.Errorf("ListDeployStat err:%v", err)
Expand Down Expand Up @@ -372,7 +372,7 @@ type deployFailureHigherStat struct {
}

func GetDeployTopFiveFailureMeasure(startDate, endDate int64, productNames []string, log *zap.SugaredLogger) ([]*deployFailureHigherStat, error) {
deployStats, err := mongodb.NewDeployStatColl().ListDeployStat(&models.DeployStatOption{StartDate: startDate, EndDate: endDate, IsAsc: true, ProductNames: productNames})
deployStats, err := mongodb.NewDeployStatColl().ListDeployStat(&models.DeployStatOption{StartDate: startDate, EndDate: endDate, IsAsc: true, ProductNames: productNames, Limit: 5})
if err != nil {
log.Errorf("ListDeployStat err:%v", err)
return nil, fmt.Errorf("ListDeployStat err:%v", err)
Expand Down
4 changes: 2 additions & 2 deletions pkg/microservice/aslan/core/stat/service/overview.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ func GetOverviewStat(log *zap.SugaredLogger) (*Overview, error) {
}
overview.EnvCount = int(envCount)

artifactCount, err := commonrepo.NewDeliveryArtifactColl().Count()
_, artifactCount, err := commonrepo.NewDeliveryArtifactColl().List(&commonrepo.DeliveryArtifactArgs{})
if err != nil {
log.Errorf("Failed to get artifact count err:%s", err)
return nil, err
}
overview.ArtifactCount = int(artifactCount)
overview.ArtifactCount = artifactCount

serviceCount, err := commonrepo.NewServiceColl().Count("")
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/microservice/aslan/core/stat/service/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type testDashboard struct {
TotalCaseCount int `json:"total_case_count"`
TotalExecCount int `json:"total_exec_count"`
Success int `json:"success"`
AverageDuration int64 `json:"average_curation"`
AverageDuration int64 `json:"average_duration"`
}

func GetTestDashboard(log *zap.SugaredLogger) (*testDashboard, error) {
Expand Down

0 comments on commit fe1722f

Please sign in to comment.