Merge pull request 'fix' (#121) from devad/pcm-coordinator:master into master
Former-commit-id: 72c6cf998c6a2ee95036df722a4d41475b03d0e0
This commit is contained in:
commit
47b6379437
|
@ -24,14 +24,22 @@ func NewCountTaskStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *C
|
|||
}
|
||||
|
||||
type taskStatus struct {
|
||||
Quantity string `json:"quantity"`
|
||||
Status string `json:"status"`
|
||||
Succeeded int `json:"Succeeded"`
|
||||
Failed int `json:"Failed"`
|
||||
Running int `json:"Running"`
|
||||
Pause int `json:"Pause"`
|
||||
}
|
||||
|
||||
func (l *CountTaskStatusLogic) CountTaskStatus() (resp *types.ListResult, err error) {
|
||||
resp = &types.ListResult{}
|
||||
var taskStatusList []*taskStatus
|
||||
err = l.svcCtx.DbEngin.Raw("select count(*) quantity, status from task group by status").Scan(&taskStatusList).Error
|
||||
sqlStr := `SELECT
|
||||
COUNT(CASE WHEN status = 'Succeeded' THEN 1 END) AS Succeeded,
|
||||
COUNT(CASE WHEN status = 'Failed' THEN 1 END) AS Failed,
|
||||
COUNT(CASE WHEN status = 'Running' THEN 1 END) AS Running,
|
||||
COUNT(CASE WHEN status = 'Pause' THEN 1 END) AS Pause
|
||||
FROM task;`
|
||||
err = l.svcCtx.DbEngin.Raw(sqlStr).Scan(&taskStatusList).Error
|
||||
if err != nil {
|
||||
logx.Errorf("CountTaskStatus() => sql execution error: %v", err)
|
||||
return nil, errors.Errorf("Description Failed to collect statistics on the status of a task. Please try again later")
|
||||
|
|
Loading…
Reference in New Issue