diff --git a/jobs/compliance-summarizer-job/job.go b/jobs/compliance-summarizer-job/job.go index d222a5acb..eabf8a3fb 100644 --- a/jobs/compliance-summarizer-job/job.go +++ b/jobs/compliance-summarizer-job/job.go @@ -137,11 +137,14 @@ func (w *Worker) RunJob(ctx context.Context, j types2.Job) error { w.logger.Info("Before adding resource finding", zap.String("platform_resource_id", f.PlatformResourceID), zap.Any("resource", resource)) jd.AddComplianceResult(w.logger, j, f, resource) - addJobSummary(controlSummary, controlView, resourceView, f) - integrationsMap[f.IntegrationID] = true - totalControls[f.ControlID] = true - if f.ComplianceStatus == types.ComplianceStatusALARM { - failedControls[f.ControlID] = true + + if f.ComplianceJobID == j.ComplianceJobID { + addJobSummary(controlSummary, controlView, resourceView, f) + integrationsMap[f.IntegrationID] = true + totalControls[f.ControlID] = true + if f.ComplianceStatus == types.ComplianceStatusALARM { + failedControls[f.ControlID] = true + } } } diff --git a/jobs/compliance-summarizer-job/types/job.go b/jobs/compliance-summarizer-job/types/job.go index 74a245fe7..ad487c436 100644 --- a/jobs/compliance-summarizer-job/types/job.go +++ b/jobs/compliance-summarizer-job/types/job.go @@ -3,8 +3,9 @@ package types import "time" type Job struct { - ID uint - RetryCount int - BenchmarkID string - CreatedAt time.Time + ID uint + ComplianceJobID uint + RetryCount int + BenchmarkID string + CreatedAt time.Time } diff --git a/services/describe/schedulers/compliance/summarizer.go b/services/describe/schedulers/compliance/summarizer.go index 0ff368a63..48883d123 100644 --- a/services/describe/schedulers/compliance/summarizer.go +++ b/services/describe/schedulers/compliance/summarizer.go @@ -245,10 +245,11 @@ func (s *JobScheduler) CreateSummarizer(benchmarkId string, jobId *uint, trigger func (s *JobScheduler) triggerSummarizer(ctx context.Context, job model.ComplianceSummarizer) error { summarizerJob := types2.Job{ - ID: job.ID, - RetryCount: job.RetryCount, - BenchmarkID: job.BenchmarkID, - CreatedAt: job.CreatedAt, + ID: job.ID, + ComplianceJobID: job.ParentJobID, + RetryCount: job.RetryCount, + BenchmarkID: job.BenchmarkID, + CreatedAt: job.CreatedAt, } jobJson, err := json.Marshal(summarizerJob) if err != nil {