Skip to content

Commit

Permalink
Merge pull request #435 from openinfradev/fix_favorite
Browse files Browse the repository at this point in the history
trivial. add appserveapps count to stack response
  • Loading branch information
ktkfree authored Apr 25, 2024
2 parents b23c457 + 0152704 commit 990049b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/model/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type Stack = struct {
Resource domain.DashboardStack
PolicyIds []string
Conf StackConf
AppServeAppCnt int
}

type StackConf struct {
Expand Down
16 changes: 16 additions & 0 deletions internal/usecase/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ func (u *StackUsecase) Get(ctx context.Context, stackId domain.StackId) (out mod
out.PrimaryCluster = true
}

// Resources
stackResources, _ := u.dashbordUsecase.GetStacks(ctx, cluster.OrganizationId)
for _, resource := range stackResources {
if resource.ID == domain.StackId(cluster.ID) {
Expand All @@ -268,6 +269,7 @@ func (u *StackUsecase) Get(ctx context.Context, stackId domain.StackId) (out mod
return out, err
}

// Grafana URL
for _, appGroup := range appGroupsInPrimaryCluster {
if appGroup.AppGroupType == domain.AppGroupType_LMA {
applications, err := u.appGroupRepo.GetApplications(ctx, appGroup.ID, domain.ApplicationType_GRAFANA)
Expand All @@ -280,6 +282,20 @@ func (u *StackUsecase) Get(ctx context.Context, stackId domain.StackId) (out mod
}
}

// Favorited
if cluster.Favorites != nil && len(*cluster.Favorites) > 0 {
out.Favorited = true
} else {
out.Favorited = false
}

// AppServeApps
appServeAppCnt, err := u.appServeAppRepo.GetNumOfAppsOnStack(ctx, cluster.OrganizationId, cluster.ID.String())
if err != nil {
log.Error(ctx, err)
}
out.AppServeAppCnt = int(appServeAppCnt)

return
}

Expand Down

0 comments on commit 990049b

Please sign in to comment.