-
Notifications
You must be signed in to change notification settings - Fork 129
/
model.go
118 lines (105 loc) · 2.78 KB
/
model.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
package model
import (
"time"
)
const (
MatchExact = "exact"
MatchAnyOf = "anyOf"
MatchStartsWith = "startsWith"
MatchContains = "contains"
MatchGreaterThan = "greaterThan"
MatchLessThan = "lessThan"
MatchGreaterThanOrEqualTo = "greaterThanOrEqualTo"
MatchLessThanOrEqualTo = "lessThanOrEqualTo"
MatchExists = "exists"
DirectionAsc = "ASC"
DirectionDesc = "DESC"
)
type Job struct {
Annotations map[string]string
Cancelled *time.Time
Cpu int64
Duplicate bool
EphemeralStorage int64
Gpu int64
JobId string
JobSet string
LastActiveRunId *string
LastTransitionTime time.Time
Memory int64
Owner string
Namespace *string
Priority int64
PriorityClass *string
Queue string
Runs []*Run
State string
Submitted time.Time
CancelReason *string
Node *string
Cluster string
ExitCode *int32
RuntimeSeconds int32
}
// PostgreSQLTime is a wrapper around time.Time that converts to UTC when
// deserializing from JSON.
//
// It exists to work around the following issue:
//
// 1. PostgreSQL serializes UTC timestamps within a JSON object in the format
// "2023-11-03T09:10:42.201577+00:00"; in particular, this format uses a
// timezone offset instead of "Z" to indicate UTC.
// 2. When deserializing this UTC timestamp, Go sets the location of the
// resulting time.Time value to "local".
// 3. Tests compare timestamps with == instead of Equal, which means that two
// time.Time values with different locations are not considered equal
// (even if they represent the same instants in time).
type PostgreSQLTime struct {
Time time.Time
}
func NewPostgreSQLTime(t *time.Time) *PostgreSQLTime {
if t == nil {
return nil
}
return &PostgreSQLTime{Time: *t}
}
func (t PostgreSQLTime) MarshalJSON() ([]byte, error) {
return t.Time.MarshalJSON()
}
func (t *PostgreSQLTime) UnmarshalJSON(b []byte) error {
if err := t.Time.UnmarshalJSON(b); err != nil {
return err
}
t.Time = t.Time.UTC()
return nil
}
type Run struct {
Cluster string
ExitCode *int32
Finished *PostgreSQLTime
JobRunState int
Node *string
Leased *PostgreSQLTime
Pending *PostgreSQLTime
RunId string
Started *PostgreSQLTime
}
type JobGroup struct {
Aggregates map[string]interface{}
Count int64
Name string
}
type Filter struct {
Field string
Match string
Value interface{}
IsAnnotation bool
}
type Order struct {
Direction string
Field string
}
type GroupedField struct {
Field string
IsAnnotation bool
}