-
Notifications
You must be signed in to change notification settings - Fork 3
/
run.go
286 lines (265 loc) · 9.06 KB
/
run.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
// Code generated by entc, DO NOT EDIT.
package ent
import (
"fmt"
"strings"
"time"
"github.com/empiricaly/recruitment/internal/ent/project"
"github.com/empiricaly/recruitment/internal/ent/run"
"github.com/empiricaly/recruitment/internal/ent/steprun"
"github.com/empiricaly/recruitment/internal/ent/template"
"github.com/facebook/ent/dialect/sql"
)
// Run is the model entity for the Run schema.
type Run struct {
config `json:"-"`
// ID of the ent.
ID string `json:"id,omitempty"`
// CreatedAt holds the value of the "created_at" field.
CreatedAt time.Time `json:"created_at,omitempty"`
// UpdatedAt holds the value of the "updated_at" field.
UpdatedAt time.Time `json:"updated_at,omitempty"`
// Status holds the value of the "status" field.
Status run.Status `json:"status,omitempty"`
// StartedAt holds the value of the "startedAt" field.
StartedAt *time.Time `json:"startedAt,omitempty"`
// EndedAt holds the value of the "endedAt" field.
EndedAt *time.Time `json:"endedAt,omitempty"`
// Name holds the value of the "name" field.
Name string `json:"name,omitempty"`
// StartAt holds the value of the "startAt" field.
StartAt *time.Time `json:"startAt,omitempty"`
// Error holds the value of the "error" field.
Error *string `json:"error,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the RunQuery when eager-loading is set.
Edges RunEdges `json:"edges"`
project_runs *string
run_current_step *string
}
// RunEdges holds the relations/edges for other nodes in the graph.
type RunEdges struct {
// Project holds the value of the project edge.
Project *Project
// Template holds the value of the template edge.
Template *Template
// CurrentStep holds the value of the currentStep edge.
CurrentStep *StepRun
// Steps holds the value of the steps edge.
Steps []*StepRun
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [4]bool
}
// ProjectOrErr returns the Project value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e RunEdges) ProjectOrErr() (*Project, error) {
if e.loadedTypes[0] {
if e.Project == nil {
// The edge project was loaded in eager-loading,
// but was not found.
return nil, &NotFoundError{label: project.Label}
}
return e.Project, nil
}
return nil, &NotLoadedError{edge: "project"}
}
// TemplateOrErr returns the Template value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e RunEdges) TemplateOrErr() (*Template, error) {
if e.loadedTypes[1] {
if e.Template == nil {
// The edge template was loaded in eager-loading,
// but was not found.
return nil, &NotFoundError{label: template.Label}
}
return e.Template, nil
}
return nil, &NotLoadedError{edge: "template"}
}
// CurrentStepOrErr returns the CurrentStep value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e RunEdges) CurrentStepOrErr() (*StepRun, error) {
if e.loadedTypes[2] {
if e.CurrentStep == nil {
// The edge currentStep was loaded in eager-loading,
// but was not found.
return nil, &NotFoundError{label: steprun.Label}
}
return e.CurrentStep, nil
}
return nil, &NotLoadedError{edge: "currentStep"}
}
// StepsOrErr returns the Steps value or an error if the edge
// was not loaded in eager-loading.
func (e RunEdges) StepsOrErr() ([]*StepRun, error) {
if e.loadedTypes[3] {
return e.Steps, nil
}
return nil, &NotLoadedError{edge: "steps"}
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Run) scanValues() []interface{} {
return []interface{}{
&sql.NullString{}, // id
&sql.NullTime{}, // created_at
&sql.NullTime{}, // updated_at
&sql.NullString{}, // status
&sql.NullTime{}, // startedAt
&sql.NullTime{}, // endedAt
&sql.NullString{}, // name
&sql.NullTime{}, // startAt
&sql.NullString{}, // error
}
}
// fkValues returns the types for scanning foreign-keys values from sql.Rows.
func (*Run) fkValues() []interface{} {
return []interface{}{
&sql.NullString{}, // project_runs
&sql.NullString{}, // run_current_step
}
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the Run fields.
func (r *Run) assignValues(values ...interface{}) error {
if m, n := len(values), len(run.Columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
if value, ok := values[0].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field id", values[0])
} else if value.Valid {
r.ID = value.String
}
values = values[1:]
if value, ok := values[0].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field created_at", values[0])
} else if value.Valid {
r.CreatedAt = value.Time
}
if value, ok := values[1].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field updated_at", values[1])
} else if value.Valid {
r.UpdatedAt = value.Time
}
if value, ok := values[2].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field status", values[2])
} else if value.Valid {
r.Status = run.Status(value.String)
}
if value, ok := values[3].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field startedAt", values[3])
} else if value.Valid {
r.StartedAt = new(time.Time)
*r.StartedAt = value.Time
}
if value, ok := values[4].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field endedAt", values[4])
} else if value.Valid {
r.EndedAt = new(time.Time)
*r.EndedAt = value.Time
}
if value, ok := values[5].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field name", values[5])
} else if value.Valid {
r.Name = value.String
}
if value, ok := values[6].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field startAt", values[6])
} else if value.Valid {
r.StartAt = new(time.Time)
*r.StartAt = value.Time
}
if value, ok := values[7].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field error", values[7])
} else if value.Valid {
r.Error = new(string)
*r.Error = value.String
}
values = values[8:]
if len(values) == len(run.ForeignKeys) {
if value, ok := values[0].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field project_runs", values[0])
} else if value.Valid {
r.project_runs = new(string)
*r.project_runs = value.String
}
if value, ok := values[1].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field run_current_step", values[1])
} else if value.Valid {
r.run_current_step = new(string)
*r.run_current_step = value.String
}
}
return nil
}
// QueryProject queries the project edge of the Run.
func (r *Run) QueryProject() *ProjectQuery {
return (&RunClient{config: r.config}).QueryProject(r)
}
// QueryTemplate queries the template edge of the Run.
func (r *Run) QueryTemplate() *TemplateQuery {
return (&RunClient{config: r.config}).QueryTemplate(r)
}
// QueryCurrentStep queries the currentStep edge of the Run.
func (r *Run) QueryCurrentStep() *StepRunQuery {
return (&RunClient{config: r.config}).QueryCurrentStep(r)
}
// QuerySteps queries the steps edge of the Run.
func (r *Run) QuerySteps() *StepRunQuery {
return (&RunClient{config: r.config}).QuerySteps(r)
}
// Update returns a builder for updating this Run.
// Note that, you need to call Run.Unwrap() before calling this method, if this Run
// was returned from a transaction, and the transaction was committed or rolled back.
func (r *Run) Update() *RunUpdateOne {
return (&RunClient{config: r.config}).UpdateOne(r)
}
// Unwrap unwraps the entity that was returned from a transaction after it was closed,
// so that all next queries will be executed through the driver which created the transaction.
func (r *Run) Unwrap() *Run {
tx, ok := r.config.driver.(*txDriver)
if !ok {
panic("ent: Run is not a transactional entity")
}
r.config.driver = tx.drv
return r
}
// String implements the fmt.Stringer.
func (r *Run) String() string {
var builder strings.Builder
builder.WriteString("Run(")
builder.WriteString(fmt.Sprintf("id=%v", r.ID))
builder.WriteString(", created_at=")
builder.WriteString(r.CreatedAt.Format(time.ANSIC))
builder.WriteString(", updated_at=")
builder.WriteString(r.UpdatedAt.Format(time.ANSIC))
builder.WriteString(", status=")
builder.WriteString(fmt.Sprintf("%v", r.Status))
if v := r.StartedAt; v != nil {
builder.WriteString(", startedAt=")
builder.WriteString(v.Format(time.ANSIC))
}
if v := r.EndedAt; v != nil {
builder.WriteString(", endedAt=")
builder.WriteString(v.Format(time.ANSIC))
}
builder.WriteString(", name=")
builder.WriteString(r.Name)
if v := r.StartAt; v != nil {
builder.WriteString(", startAt=")
builder.WriteString(v.Format(time.ANSIC))
}
if v := r.Error; v != nil {
builder.WriteString(", error=")
builder.WriteString(*v)
}
builder.WriteByte(')')
return builder.String()
}
// Runs is a parsable slice of Run.
type Runs []*Run
func (r Runs) config(cfg config) {
for _i := range r {
r[_i].config = cfg
}
}