Skip to content

Commit

Permalink
Merge pull request #1941 from opengovern/fix-web-ui
Browse files Browse the repository at this point in the history
fix: fix summarizer resource lookup
  • Loading branch information
artaasadi authored Nov 11, 2024
2 parents 5eb47ed + bcca7bc commit b6ab9bf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions pkg/compliance/es/lookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ type LookupQueryResponse struct {
} `json:"aggregations"`
}

func FetchLookupByResourceIDBatch(ctx context.Context, client opengovernance.Client, resourceID []string) (map[string][]es.LookupResource, error) {
if len(resourceID) == 0 {
func FetchLookupByResourceIDBatch(ctx context.Context, client opengovernance.Client, platformResourceIDs []string) (map[string][]es.LookupResource, error) {
if len(platformResourceIDs) == 0 {
return nil, nil
}
request := make(map[string]any)
Expand All @@ -45,16 +45,16 @@ func FetchLookupByResourceIDBatch(ctx context.Context, client opengovernance.Cli
"bool": map[string]any{
"filter": map[string]any{
"terms": map[string]any{
"resource_id": resourceID,
"platform_id": platformResourceIDs,
},
},
},
}
request["aggs"] = map[string]any{
"resources": map[string]any{
"terms": map[string]any{
"field": "resource_id",
"size": len(resourceID),
"field": "platform_id",
"size": len(platformResourceIDs),
},
"aggs": map[string]any{
"hit_select": map[string]any{
Expand Down
6 changes: 3 additions & 3 deletions pkg/compliance/summarizer/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ func (w *Worker) RunJob(ctx context.Context, j types2.Job) error {
return err
}

resourceIds := make([]string, 0, len(page))
platformResourceIDs := make([]string, 0, len(page))
for _, f := range page {
resourceIds = append(resourceIds, f.PlatformResourceID)
platformResourceIDs = append(platformResourceIDs, f.PlatformResourceID)
}

lookupResourcesMap, err := es.FetchLookupByResourceIDBatch(ctx, w.esClient, resourceIds)
lookupResourcesMap, err := es.FetchLookupByResourceIDBatch(ctx, w.esClient, platformResourceIDs)
if err != nil {
w.logger.Error("failed to fetch lookup resources", zap.Error(err))
return err
Expand Down

0 comments on commit b6ab9bf

Please sign in to comment.