-
Notifications
You must be signed in to change notification settings - Fork 152
Expand file tree
/
Copy pathbun_models_ci.go
More file actions
129 lines (119 loc) · 4.44 KB
/
Copy pathbun_models_ci.go
File metadata and controls
129 lines (119 loc) · 4.44 KB
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
package storage
import "github.com/uptrace/bun"
var sqliteCIPanelColumns = []string{
"id",
"github_repo",
"pr_number",
"head_sha",
"panel_run_uuid",
"synthesis_job_id",
"created_at",
"posting_claimed_at",
"posted_at",
"retired_at",
"outcome",
"first_attempt_at",
"attempt_count",
"synthesis_agent",
"synthesis_model",
"allow_stale_post",
}
var sqliteReviewAttemptColumns = []string{
"id", "github_repo", "pr_number", "head_sha", "attempt",
"first_attempt_at", "next_attempt_at", "last_error_class",
"consecutive_genuine_attempts", "last_error_excerpt",
"last_panel_run_uuid", "state", "updated_at",
}
type ciPRReviewRow struct {
bun.BaseModel `bun:"table:ci_pr_reviews,alias:cpr"`
ID int64 `bun:"id,pk,autoincrement"`
GithubRepo string `bun:"github_repo"`
PRNumber int `bun:"pr_number"`
HeadSHA string `bun:"head_sha"`
JobID int64 `bun:"job_id"`
CreatedAt dbTime `bun:"created_at"`
}
type ciPanelRow struct {
bun.BaseModel `bun:"table:ci_pr_panels,alias:cp"`
ID int64 `bun:"id,pk,autoincrement"`
GithubRepo string `bun:"github_repo"`
PRNumber int `bun:"pr_number"`
HeadSHA string `bun:"head_sha"`
PanelRunUUID string `bun:"panel_run_uuid"`
SynthesisJobID *int64 `bun:"synthesis_job_id"`
CreatedAt dbTime `bun:"created_at"`
PostingClaimedAt dbTime `bun:"posting_claimed_at"`
PostedAt dbTime `bun:"posted_at"`
RetiredAt dbTime `bun:"retired_at"`
Outcome *string `bun:"outcome"`
FirstAttemptAt dbTime `bun:"first_attempt_at"`
AttemptCount *int64 `bun:"attempt_count"`
SynthesisAgent *string `bun:"synthesis_agent"`
SynthesisModel *string `bun:"synthesis_model"`
AllowStalePost bool `bun:"allow_stale_post"`
}
func (row ciPanelRow) toModel() CIPanel {
panel := CIPanel{
ID: row.ID,
GithubRepo: row.GithubRepo,
PRNumber: row.PRNumber,
HeadSHA: row.HeadSHA,
PanelRunUUID: row.PanelRunUUID,
SynthesisJobID: cloneInt64Pointer(row.SynthesisJobID),
CreatedAt: row.CreatedAt.Time,
PostingClaimedAt: row.PostingClaimedAt.pointer(),
PostedAt: row.PostedAt.pointer(),
RetiredAt: row.RetiredAt.pointer(),
Outcome: cloneStringPointer(row.Outcome),
FirstAttemptAt: row.FirstAttemptAt.pointer(),
AttemptCount: cloneInt64Pointer(row.AttemptCount),
SynthesisAgent: cloneStringPointer(row.SynthesisAgent),
SynthesisModel: cloneStringPointer(row.SynthesisModel),
AllowStalePost: row.AllowStalePost,
}
return panel
}
type ciReviewAttemptRow struct {
bun.BaseModel `bun:"table:ci_pr_review_attempts,alias:ca"`
ID int64 `bun:"id,pk,autoincrement"`
GithubRepo string `bun:"github_repo"`
PRNumber int `bun:"pr_number"`
HeadSHA string `bun:"head_sha"`
Attempt int `bun:"attempt"`
FirstAttemptAt dbTime `bun:"first_attempt_at"`
NextAttemptAt dbTime `bun:"next_attempt_at"`
LastErrorClass string `bun:"last_error_class"`
ConsecutiveGenuineAttempts int `bun:"consecutive_genuine_attempts"`
LastErrorExcerpt string `bun:"last_error_excerpt"`
LastPanelRunUUID string `bun:"last_panel_run_uuid"`
State string `bun:"state"`
UpdatedAt dbTime `bun:"updated_at"`
}
func (row ciReviewAttemptRow) toModel() ReviewAttempt {
return ReviewAttempt{
ID: row.ID,
GithubRepo: row.GithubRepo,
PRNumber: row.PRNumber,
HeadSHA: row.HeadSHA,
Attempt: row.Attempt,
FirstAttemptAt: row.FirstAttemptAt.Time,
NextAttemptAt: row.NextAttemptAt.pointer(),
LastErrorClass: row.LastErrorClass,
ConsecutiveGenuineAttempts: row.ConsecutiveGenuineAttempts,
LastErrorExcerpt: row.LastErrorExcerpt,
LastPanelRunUUID: row.LastPanelRunUUID,
State: row.State,
UpdatedAt: row.UpdatedAt.Time,
}
}
type daemonStateRow struct {
bun.BaseModel `bun:"table:daemon_state,alias:ds"`
Key string `bun:"key,pk"`
Value string `bun:"value"`
UpdatedAt dbTime `bun:"updated_at"`
}
type syncStateRow struct {
bun.BaseModel `bun:"table:sync_state,alias:ss"`
Key string `bun:"key,pk"`
Value string `bun:"value"`
}