-
Notifications
You must be signed in to change notification settings - Fork 0
/
record.go
44 lines (37 loc) · 1.06 KB
/
record.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package sql_execution_repository
import (
"time"
"github.com/awlsring/texit/internal/pkg/domain/workflow"
)
type ExecutionSqlRecord struct {
Identifier string `db:"identifier"`
Workflow string `db:"workflow"`
Status string `db:"status"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
FinishedAt *time.Time `db:"finished_at"`
Results *string `db:"results"`
}
func (n *ExecutionSqlRecord) ToExecution() *workflow.Execution {
wf, err := workflow.WorkflowNameFromString(n.Workflow)
if err != nil {
wf = workflow.WorkflowNameUnknown
}
status, err := workflow.StatusFromString(n.Status)
if err != nil {
status = workflow.StatusUnknown
}
results := workflow.SerializedExecutionResult("")
if n.Results != nil {
results = workflow.SerializedExecutionResult(*n.Results)
}
return &workflow.Execution{
Identifier: workflow.ExecutionIdentifier(n.Identifier),
Workflow: wf,
Status: status,
Created: n.CreatedAt,
Updated: n.UpdatedAt,
Finished: n.FinishedAt,
Results: results,
}
}