mirror of
https://github.com/onepanelio/onepanel.git
synced 2025-11-02 20:04:01 +08:00
Adding code to return the WorkflowStatistics with the ListTemplates
response.
This commit is contained in:
@@ -1112,27 +1112,27 @@ func (c *Client) GetWorkflowExecutionStatisticsForTemplate(workflowTemplate *Wor
|
||||
return err
|
||||
}
|
||||
|
||||
workflowTemplate.WorkflowExecutionStatistic = &WorkflowExecutionStatisticReport{}
|
||||
workflowTemplate.WorkflowExecutionStatisticReport = &WorkflowExecutionStatisticReport{}
|
||||
if len(workflowExecStats) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
//Calculate and set the values
|
||||
workflowTemplate.WorkflowExecutionStatistic.Total = uint64(len(workflowExecStats))
|
||||
workflowTemplate.WorkflowExecutionStatisticReport.Total = uint64(len(workflowExecStats))
|
||||
createdAtTime, ok := (workflowExecStats[0].CreatedAt).(time.Time)
|
||||
if !ok {
|
||||
return errors.New("Unable to get time of created_at")
|
||||
}
|
||||
workflowTemplate.WorkflowExecutionStatistic.LastExecuted = createdAtTime
|
||||
workflowTemplate.WorkflowExecutionStatisticReport.LastExecuted = createdAtTime
|
||||
for _, workflowExecStat := range workflowExecStats {
|
||||
if workflowExecStat.FailedAt != nil {
|
||||
workflowTemplate.WorkflowExecutionStatistic.Failed++
|
||||
workflowTemplate.WorkflowExecutionStatisticReport.Failed++
|
||||
}
|
||||
if workflowExecStat.FinishedAt == nil {
|
||||
workflowTemplate.WorkflowExecutionStatistic.Running++
|
||||
workflowTemplate.WorkflowExecutionStatisticReport.Running++
|
||||
}
|
||||
if workflowExecStat.FinishedAt != nil {
|
||||
workflowTemplate.WorkflowExecutionStatistic.Completed++
|
||||
workflowTemplate.WorkflowExecutionStatisticReport.Completed++
|
||||
}
|
||||
}
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user