fix: correct completed in the metrics of the scan all (#14003)

Correct the completed count in the metrics of the scan all to be the sum
of success, error and stopped count.

Closes #14001

Signed-off-by: He Weiwei <hweiwei@vmware.com>
This commit is contained in:
He Weiwei 2021-01-15 10:26:34 +08:00 committed by GitHub
parent 17652c06a2
commit 74d055b26b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 6 deletions

View File

@ -203,13 +203,11 @@ func (s *scanAllAPI) getMetrics(ctx context.Context, trigger ...string) (*models
sts := &models.Stats{}
if execution != nil {
metrics := execution.Metrics
sts.Total = metrics.TaskCount
sts.Completed = metrics.SuccessTaskCount
sts.Ongoing = !job.Status(execution.Status).Final() || sts.Total != sts.Completed
sts.Trigger = strings.Title(strings.ToLower(execution.Trigger))
if execution.Metrics != nil {
metrics := execution.Metrics
sts.Total = metrics.TaskCount
sts.Completed = metrics.SuccessTaskCount + metrics.ErrorTaskCount + metrics.StoppedTaskCount
sts.Metrics = map[string]int64{
"Pending": metrics.PendingTaskCount,
"Running": metrics.RunningTaskCount,
@ -218,6 +216,8 @@ func (s *scanAllAPI) getMetrics(ctx context.Context, trigger ...string) (*models
"Stopped": metrics.StoppedTaskCount,
}
} else {
sts.Total = 0
sts.Completed = 0
sts.Metrics = map[string]int64{
"Pending": 0,
"Running": 0,
@ -226,6 +226,9 @@ func (s *scanAllAPI) getMetrics(ctx context.Context, trigger ...string) (*models
"Stopped": 0,
}
}
sts.Ongoing = !job.Status(execution.Status).Final() || sts.Total != sts.Completed
sts.Trigger = strings.Title(strings.ToLower(execution.Trigger))
}
return sts, nil