From d79bf5e4cd27c6dacde508a86a159cb102038be2 Mon Sep 17 00:00:00 2001 From: artaasadi Date: Wed, 13 Nov 2024 22:52:53 +0100 Subject: [PATCH] fix: fix get controls --- pkg/compliance/http_routes.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pkg/compliance/http_routes.go b/pkg/compliance/http_routes.go index 0115fa359..dd7723df8 100644 --- a/pkg/compliance/http_routes.go +++ b/pkg/compliance/http_routes.go @@ -3526,9 +3526,10 @@ func (h *HttpHandler) ListControlsFiltered(echoCtx echo.Context) error { apiControl.Query.Parameters = append(apiControl.Query.Parameters, p.ToApi()) } - controlSummary, err := h.getControlSummary(ctx, control.ID, nil, integrationIDs) + h.logger.Info("ListControlsByFilter", zap.Strings("benchmarks", benchmarks)) + controlResult, _, err := es.BenchmarksControlSummary(ctx, h.logger, h.client, benchmarks, nil) if err != nil { - return err + h.logger.Error("failed to fetch control result", zap.Error(err), zap.String("controlID", control.ID), zap.Any("benchmarkID", benchmarks)) } if req.ComplianceResultSummary { @@ -3558,10 +3559,10 @@ func (h *HttpHandler) ListControlsFiltered(echoCtx echo.Context) error { }{ IncidentCount: incidentCount, NonIncidentCount: passingComplianceResultCount, - CompliantResources: controlSummary.TotalResourcesCount - controlSummary.FailedResourcesCount, - NonCompliantResources: controlSummary.FailedResourcesCount, - ImpactedResources: controlSummary.TotalResourcesCount, - CostImpact: controlSummary.CostImpact, + CompliantResources: controlResult[control.ID].TotalResourcesCount - controlResult[control.ID].FailedResourcesCount, + NonCompliantResources: controlResult[control.ID].FailedResourcesCount, + ImpactedResources: controlResult[control.ID].TotalResourcesCount, + CostImpact: controlResult[control.ID].CostImpact, } }