Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Flattened task/report. #453

Merged
merged 1 commit into from
Jul 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 19 additions & 11 deletions api/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,15 +518,15 @@ type Task struct {
Application *Ref `json:"application,omitempty" yaml:",omitempty"`
State string `json:"state"`
Image string `json:"image,omitempty" yaml:",omitempty"`
Bucket *Ref `json:"bucket,omitempty" yaml:",omitempty"`
Purged bool `json:"purged,omitempty" yaml:",omitempty"`
Started *time.Time `json:"started,omitempty" yaml:",omitempty"`
Terminated *time.Time `json:"terminated,omitempty" yaml:",omitempty"`
Errors []TaskError `json:"errors,omitempty" yaml:",omitempty"`
Pod string `json:"pod,omitempty" yaml:",omitempty"`
Retries int `json:"retries,omitempty" yaml:",omitempty"`
Started *time.Time `json:"started,omitempty" yaml:",omitempty"`
Terminated *time.Time `json:"terminated,omitempty" yaml:",omitempty"`
Canceled bool `json:"canceled,omitempty" yaml:",omitempty"`
Report *TaskReport `json:"report,omitempty" yaml:",omitempty"`
Bucket *Ref `json:"bucket,omitempty" yaml:",omitempty"`
Purged bool `json:"purged,omitempty" yaml:",omitempty"`
Errors []TaskError `json:"errors,omitempty" yaml:",omitempty"`
Activity []string `json:"activity,omitempty" yaml:",omitempty"`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hint: just re-ordered a few fields.

}

//
Expand All @@ -549,17 +549,25 @@ func (r *Task) With(m *model.Task) {
r.Retries = m.Retries
r.Canceled = m.Canceled
_ = json.Unmarshal(m.Data, &r.Data)
if m.Report != nil {
report := &TaskReport{}
report.With(m.Report)
r.Report = report
}
if m.TTL != nil {
_ = json.Unmarshal(m.TTL, &r.TTL)
}
if m.Errors != nil {
_ = json.Unmarshal(m.Errors, &r.Errors)
}
if m.Report != nil {
report := &TaskReport{}
report.With(m.Report)
r.Activity = report.Activity
r.Errors = append(report.Errors, r.Errors...)
switch r.State {
case tasking.Succeeded:
switch report.Status {
case tasking.Failed:
r.State = report.Status
}
}
}
}

//
Expand Down
Loading