diff --git a/modules/core-services/services/project/project.go b/modules/core-services/services/project/project.go index 0fd75dd96e1..63ec5c61234 100644 --- a/modules/core-services/services/project/project.go +++ b/modules/core-services/services/project/project.go @@ -1255,7 +1255,15 @@ func (p *Project) convertToProjectDTO(joined bool, project *model.Project) apist l.WithError(err).Errorln("failed to Unmarshal project.ClusterConfig") } - total, _ := p.db.GetApplicationCountByProjectID(project.ID) + totalApp, err := p.db.GetApplicationCountByProjectID(project.ID) + if err != nil { + l.WithError(err).Errorln("failed to count app") + } + + totalMember, _, err := p.db.GetMembersWithoutExtraByScope(apistructs.ProjectScope, project.ID) + if err != nil { + l.WithError(err).Errorln("failed to count member") + } projectDto := apistructs.ProjectDTO{ ID: uint64(project.ID), @@ -1268,7 +1276,8 @@ func (p *Project) convertToProjectDTO(joined bool, project *model.Project) apist Creator: project.UserID, DDHook: project.DDHook, Stats: apistructs.ProjectStats{ - CountApplications: int(total), + CountApplications: int(totalApp), + CountMembers: totalMember, }, ClusterConfig: clusterConfig, RollbackConfig: rollbackConfig, diff --git a/modules/dop/endpoints/project.go b/modules/dop/endpoints/project.go index 17bdb653201..cef5d8859f8 100644 --- a/modules/dop/endpoints/project.go +++ b/modules/dop/endpoints/project.go @@ -305,27 +305,6 @@ func (e *Endpoints) ListProject(ctx context.Context, r *http.Request, vars map[s return apierrors.ErrListProject.InternalError(err).ToResp(), nil } - // rich statistical data - if params.PageSize <= 15 { - Once.Do(func() { - ProjectStatsCache = &sync.Map{} - }) - for i := range pagingProjects.List { - prjID := int64(pagingProjects.List[i].ID) - stats, ok := ProjectStatsCache.Load(prjID) - if !ok { - logrus.Infof("get a new project %v add in cache", prjID) - stats, err = e.getProjectStats(uint64(prjID)) - if err != nil { - logrus.Errorf("fail to getProjectStats,%v", err) - continue - } - ProjectStatsCache.Store(prjID, stats) - } - pagingProjects.List[i].Stats = *stats.(*apistructs.ProjectStats) - } - } - var userIDs []string for _, v := range pagingProjects.List { userIDs = append(userIDs, v.Owners...) diff --git a/modules/dop/initialize.go b/modules/dop/initialize.go index 1da0bd12be6..a649aaadfe0 100644 --- a/modules/dop/initialize.go +++ b/modules/dop/initialize.go @@ -123,8 +123,6 @@ func (p *provider) Initialize(ctx servicehub.Context) error { registerWebHook(bdl.Bdl) - go endpoints.SetProjectStatsCache() - // 注册 hook if err := ep.RegisterEvents(); err != nil { return err