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

task_step.go 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright 2022 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package actions
  4. import (
  5. "context"
  6. "time"
  7. "code.gitea.io/gitea/models/db"
  8. "code.gitea.io/gitea/modules/timeutil"
  9. )
  10. // ActionTaskStep represents a step of ActionTask
  11. type ActionTaskStep struct {
  12. ID int64
  13. Name string `xorm:"VARCHAR(255)"`
  14. TaskID int64 `xorm:"index unique(task_index)"`
  15. Index int64 `xorm:"index unique(task_index)"`
  16. RepoID int64 `xorm:"index"`
  17. Status Status `xorm:"index"`
  18. LogIndex int64
  19. LogLength int64
  20. Started timeutil.TimeStamp
  21. Stopped timeutil.TimeStamp
  22. Created timeutil.TimeStamp `xorm:"created"`
  23. Updated timeutil.TimeStamp `xorm:"updated"`
  24. }
  25. func (step *ActionTaskStep) Duration() time.Duration {
  26. return calculateDuration(step.Started, step.Stopped, step.Status)
  27. }
  28. func init() {
  29. db.RegisterModel(new(ActionTaskStep))
  30. }
  31. func GetTaskStepsByTaskID(ctx context.Context, taskID int64) ([]*ActionTaskStep, error) {
  32. var steps []*ActionTaskStep
  33. return steps, db.GetEngine(ctx).Where("task_id=?", taskID).OrderBy("`index` ASC").Find(&steps)
  34. }