···109 repo_at text not null,
110 pull_id integer not null,
111 title text not null,
0112 patch text,
113- patch_at text not null,
00114 open integer not null default 1,
115 created text not null default (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
116 unique(repo_at, pull_id),
···109 repo_at text not null,
110 pull_id integer not null,
111 title text not null,
112+ body text not null,
113 patch text,
114+ pull_at text,
115+ rkey text not null,
116+ target_branch text not null,
117 open integer not null default 1,
118 created text not null default (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
119 unique(repo_at, pull_id),
+46-43
appview/db/pulls.go
···7 "github.com/bluesky-social/indigo/atproto/syntax"
8)
910-type Pulls struct {
11- ID int `json:"id"`
12- OwnerDid string `json:"owner_did"`
13- RepoAt string `json:"repo_at"`
14- PullId int `json:"pull_id"`
15- Title string `json:"title"`
16- Patch string `json:"patch,omitempty"`
17- PatchAt string `json:"patch_at"`
18- Open int `json:"open"`
19- Created time.Time `json:"created"`
00020}
2122-type PullComments struct {
23- ID int `json:"id"`
24- OwnerDid string `json:"owner_did"`
25- PullId int `json:"pull_id"`
26- RepoAt string `json:"repo_at"`
27- CommentId int `json:"comment_id"`
28- CommentAt string `json:"comment_at"`
29- Body string `json:"body"`
30- Created time.Time `json:"created"`
31}
3233-func NewPull(tx *sql.Tx, pull *Pulls) error {
34 defer tx.Rollback()
3536 _, err := tx.Exec(`
···55 pull.PullId = nextId
5657 _, err = tx.Exec(`
58- insert into pulls (repo_at, owner_did, pull_id, title, patch)
59- values (?, ?, ?, ?, ?)
60- `, pull.RepoAt, pull.OwnerDid, pull.PullId, pull.Title, pull.Patch)
61 if err != nil {
62 return err
63 }
···70}
7172func SetPullAt(e Execer, repoAt syntax.ATURI, pullId int, pullAt string) error {
73- _, err := e.Exec(`update pulls set patch_at = ? where repo_at = ? and pull_id = ?`, pullAt, repoAt, pullId)
74 return err
75}
7677func GetPullAt(e Execer, repoAt syntax.ATURI, pullId int) (string, error) {
78 var pullAt string
79- err := e.QueryRow(`select patch_at from pulls where repo_at = ? and pull_id = ?`, repoAt, pullId).Scan(&pullAt)
80 return pullAt, err
81}
82···92 return ownerDid, err
93}
9495-func GetPulls(e Execer, repoAt syntax.ATURI) ([]Pulls, error) {
96- var pulls []Pulls
9798- rows, err := e.Query(`select owner_did, pull_id, created, title, patch, open from pulls where repo_at = ? order by created desc`, repoAt)
99 if err != nil {
100 return nil, err
101 }
102 defer rows.Close()
103104 for rows.Next() {
105- var pull Pulls
106 var createdAt string
107- err := rows.Scan(&pull.OwnerDid, &pull.PullId, &createdAt, &pull.Title, &pull.Patch, &pull.Open)
108 if err != nil {
109 return nil, err
110 }
···125 return pulls, nil
126}
127128-func GetPull(e Execer, repoAt syntax.ATURI, pullId int) (*Pulls, error) {
129- query := `select owner_did, created, title, patch, open from pulls where repo_at = ? and pull_id = ?`
130 row := e.QueryRow(query, repoAt, pullId)
131132- var pull Pulls
133 var createdAt string
134- err := row.Scan(&pull.OwnerDid, &createdAt, &pull.Title, &pull.Patch, &pull.Open)
135 if err != nil {
136 return nil, err
137 }
···145 return &pull, nil
146}
147148-func GetPullWithComments(e Execer, repoAt syntax.ATURI, pullId int) (*Pulls, []PullComments, error) {
149- query := `select owner_did, pull_id, created, title, patch, open from pulls where repo_at = ? and pull_id = ?`
150 row := e.QueryRow(query, repoAt, pullId)
151152- var pull Pulls
153 var createdAt string
154- err := row.Scan(&pull.OwnerDid, &pull.PullId, &createdAt, &pull.Title, &pull.Patch, &pull.Open)
155 if err != nil {
156 return nil, nil, err
157 }
···170 return &pull, comments, nil
171}
172173-func NewPullComment(e Execer, comment *PullComments) error {
174 query := `insert into pull_comments (owner_did, repo_at, comment_at, pull_id, comment_id, body) values (?, ?, ?, ?, ?, ?)`
175 _, err := e.Exec(
176 query,
···184 return err
185}
186187-func GetPullComments(e Execer, repoAt syntax.ATURI, pullId int) ([]PullComments, error) {
188- var comments []PullComments
189190 rows, err := e.Query(`select owner_did, pull_id, comment_id, comment_at, body, created from pull_comments where repo_at = ? and pull_id = ? order by created asc`, repoAt, pullId)
191 if err == sql.ErrNoRows {
192- return []PullComments{}, nil
193 }
194 if err != nil {
195 return nil, err
···197 defer rows.Close()
198199 for rows.Next() {
200- var comment PullComments
201 var createdAt string
202 err := rows.Scan(&comment.OwnerDid, &comment.PullId, &comment.CommentId, &comment.CommentAt, &comment.Body, &createdAt)
203 if err != nil {
···7 "github.com/bluesky-social/indigo/atproto/syntax"
8)
910+type Pull struct {
11+ ID int
12+ OwnerDid string
13+ RepoAt syntax.ATURI
14+ PullAt syntax.ATURI
15+ TargetBranch string
16+ Patch string
17+ PullId int
18+ Title string
19+ Body string
20+ Open int
21+ Created time.Time
22+ Rkey string
23}
2425+type PullComment struct {
26+ ID int
27+ OwnerDid string
28+ PullId int
29+ RepoAt string
30+ CommentId int
31+ CommentAt string
32+ Body string
33+ Created time.Time
34}
3536+func NewPull(tx *sql.Tx, pull *Pull) error {
37 defer tx.Rollback()
3839 _, err := tx.Exec(`
···58 pull.PullId = nextId
5960 _, err = tx.Exec(`
61+ insert into pulls (repo_at, owner_did, pull_id, title, target_branch, body, patch, rkey)
62+ values (?, ?, ?, ?, ?, ?, ?, ?)
63+ `, pull.RepoAt, pull.OwnerDid, pull.PullId, pull.Title, pull.TargetBranch, pull.Body, pull.Patch, pull.Rkey)
64 if err != nil {
65 return err
66 }
···73}
7475func SetPullAt(e Execer, repoAt syntax.ATURI, pullId int, pullAt string) error {
76+ _, err := e.Exec(`update pulls set pull_at = ? where repo_at = ? and pull_id = ?`, pullAt, repoAt, pullId)
77 return err
78}
7980func GetPullAt(e Execer, repoAt syntax.ATURI, pullId int) (string, error) {
81 var pullAt string
82+ err := e.QueryRow(`select pull_at from pulls where repo_at = ? and pull_id = ?`, repoAt, pullId).Scan(&pullAt)
83 return pullAt, err
84}
85···95 return ownerDid, err
96}
9798+func GetPulls(e Execer, repoAt syntax.ATURI) ([]Pull, error) {
99+ var pulls []Pull
100101+ rows, err := e.Query(`select owner_did, pull_id, created, title, open, target_branch, pull_at, body, patch, rkey from pulls where repo_at = ? order by created desc`, repoAt)
102 if err != nil {
103 return nil, err
104 }
105 defer rows.Close()
106107 for rows.Next() {
108+ var pull Pull
109 var createdAt string
110+ err := rows.Scan(&pull.OwnerDid, &pull.PullId, &createdAt, &pull.Title, &pull.Open, &pull.TargetBranch, &pull.PullAt, &pull.Body, &pull.Patch, &pull.Rkey)
111 if err != nil {
112 return nil, err
113 }
···128 return pulls, nil
129}
130131+func GetPull(e Execer, repoAt syntax.ATURI, pullId int) (*Pull, error) {
132+ query := `select owner_did, created, title, open, target_branch, pull_at, body, patch, rkey from pulls where repo_at = ? and pull_id = ?`
133 row := e.QueryRow(query, repoAt, pullId)
134135+ var pull Pull
136 var createdAt string
137+ err := row.Scan(&pull.OwnerDid, &createdAt, &pull.Title, &pull.Open, &pull.TargetBranch, &pull.PullAt, &pull.Body, &pull.Patch, &pull.Rkey)
138 if err != nil {
139 return nil, err
140 }
···148 return &pull, nil
149}
150151+func GetPullWithComments(e Execer, repoAt syntax.ATURI, pullId int) (*Pull, []PullComment, error) {
152+ query := `select owner_did, pull_id, created, title, open, target_branch, pull_at, body, patch, rkey from pulls where repo_at = ? and pull_id = ?`
153 row := e.QueryRow(query, repoAt, pullId)
154155+ var pull Pull
156 var createdAt string
157+ err := row.Scan(&pull.OwnerDid, &pull.PullId, &createdAt, &pull.Title, &pull.Open, &pull.TargetBranch, &pull.PullAt, &pull.Body, &pull.Patch, &pull.Rkey)
158 if err != nil {
159 return nil, nil, err
160 }
···173 return &pull, comments, nil
174}
175176+func NewPullComment(e Execer, comment *PullComment) error {
177 query := `insert into pull_comments (owner_did, repo_at, comment_at, pull_id, comment_id, body) values (?, ?, ?, ?, ?, ?)`
178 _, err := e.Exec(
179 query,
···187 return err
188}
189190+func GetPullComments(e Execer, repoAt syntax.ATURI, pullId int) ([]PullComment, error) {
191+ var comments []PullComment
192193 rows, err := e.Query(`select owner_did, pull_id, comment_id, comment_at, body, created from pull_comments where repo_at = ? and pull_id = ? order by created asc`, repoAt, pullId)
194 if err == sql.ErrNoRows {
195+ return []PullComment{}, nil
196 }
197 if err != nil {
198 return nil, err
···200 defer rows.Close()
201202 for rows.Next() {
203+ var comment PullComment
204 var createdAt string
205 err := rows.Scan(&comment.OwnerDid, &comment.PullId, &comment.CommentId, &comment.CommentAt, &comment.Body, &createdAt)
206 if err != nil {