You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

counttaskstatuslogic.go 1.2 kB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package core
  2. import (
  3. "context"
  4. "github.com/pkg/errors"
  5. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
  6. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
  7. "github.com/zeromicro/go-zero/core/logx"
  8. )
  9. type CountTaskStatusLogic struct {
  10. logx.Logger
  11. ctx context.Context
  12. svcCtx *svc.ServiceContext
  13. }
  14. func NewCountTaskStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CountTaskStatusLogic {
  15. return &CountTaskStatusLogic{
  16. Logger: logx.WithContext(ctx),
  17. ctx: ctx,
  18. svcCtx: svcCtx,
  19. }
  20. }
  21. func (l *CountTaskStatusLogic) CountTaskStatus() (resp *types.TaskStatusResp, err error) {
  22. resp = &types.TaskStatusResp{}
  23. sqlStr := `SELECT
  24. COUNT(CASE WHEN status = 'Succeeded' THEN 1 END) AS Succeeded,
  25. COUNT(CASE WHEN status = 'Failed' THEN 1 END) AS Failed,
  26. COUNT(CASE WHEN status = 'Running' THEN 1 END) AS Running,
  27. COUNT(CASE WHEN status = 'Saved' THEN 1 END) AS Saved
  28. FROM task;`
  29. err = l.svcCtx.DbEngin.Raw(sqlStr).Scan(&resp).Error
  30. if err != nil {
  31. logx.Errorf("CountTaskStatus() => sql execution error: %v", err)
  32. return nil, errors.Errorf("Description Failed to collect statistics on the status of a task. Please try again later")
  33. }
  34. return
  35. }

PCM is positioned as Software stack over Cloud, aiming to build the standards and ecology of heterogeneous cloud collaboration for JCC in a non intrusive and autonomous peer-to-peer manner.