···109109 repo_at text not null,
110110 pull_id integer not null,
111111 title text not null,
112112+ body text not null,
112113 patch text,
113113- patch_at text not null,
114114+ pull_at text,
115115+ rkey text not null,
116116+ target_branch text not null,
114117 open integer not null default 1,
115118 created text not null default (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
116119 unique(repo_at, pull_id),
+46-43
appview/db/pulls.go
···77 "github.com/bluesky-social/indigo/atproto/syntax"
88)
991010-type Pulls struct {
1111- ID int `json:"id"`
1212- OwnerDid string `json:"owner_did"`
1313- RepoAt string `json:"repo_at"`
1414- PullId int `json:"pull_id"`
1515- Title string `json:"title"`
1616- Patch string `json:"patch,omitempty"`
1717- PatchAt string `json:"patch_at"`
1818- Open int `json:"open"`
1919- Created time.Time `json:"created"`
1010+type Pull struct {
1111+ ID int
1212+ OwnerDid string
1313+ RepoAt syntax.ATURI
1414+ PullAt syntax.ATURI
1515+ TargetBranch string
1616+ Patch string
1717+ PullId int
1818+ Title string
1919+ Body string
2020+ Open int
2121+ Created time.Time
2222+ Rkey string
2023}
21242222-type PullComments struct {
2323- ID int `json:"id"`
2424- OwnerDid string `json:"owner_did"`
2525- PullId int `json:"pull_id"`
2626- RepoAt string `json:"repo_at"`
2727- CommentId int `json:"comment_id"`
2828- CommentAt string `json:"comment_at"`
2929- Body string `json:"body"`
3030- Created time.Time `json:"created"`
2525+type PullComment struct {
2626+ ID int
2727+ OwnerDid string
2828+ PullId int
2929+ RepoAt string
3030+ CommentId int
3131+ CommentAt string
3232+ Body string
3333+ Created time.Time
3134}
32353333-func NewPull(tx *sql.Tx, pull *Pulls) error {
3636+func NewPull(tx *sql.Tx, pull *Pull) error {
3437 defer tx.Rollback()
35383639 _, err := tx.Exec(`
···5558 pull.PullId = nextId
56595760 _, err = tx.Exec(`
5858- insert into pulls (repo_at, owner_did, pull_id, title, patch)
5959- values (?, ?, ?, ?, ?)
6060- `, pull.RepoAt, pull.OwnerDid, pull.PullId, pull.Title, pull.Patch)
6161+ insert into pulls (repo_at, owner_did, pull_id, title, target_branch, body, patch, rkey)
6262+ values (?, ?, ?, ?, ?, ?, ?, ?)
6363+ `, pull.RepoAt, pull.OwnerDid, pull.PullId, pull.Title, pull.TargetBranch, pull.Body, pull.Patch, pull.Rkey)
6164 if err != nil {
6265 return err
6366 }
···7073}
71747275func SetPullAt(e Execer, repoAt syntax.ATURI, pullId int, pullAt string) error {
7373- _, err := e.Exec(`update pulls set patch_at = ? where repo_at = ? and pull_id = ?`, pullAt, repoAt, pullId)
7676+ _, err := e.Exec(`update pulls set pull_at = ? where repo_at = ? and pull_id = ?`, pullAt, repoAt, pullId)
7477 return err
7578}
76797780func GetPullAt(e Execer, repoAt syntax.ATURI, pullId int) (string, error) {
7881 var pullAt string
7979- err := e.QueryRow(`select patch_at from pulls where repo_at = ? and pull_id = ?`, repoAt, pullId).Scan(&pullAt)
8282+ err := e.QueryRow(`select pull_at from pulls where repo_at = ? and pull_id = ?`, repoAt, pullId).Scan(&pullAt)
8083 return pullAt, err
8184}
8285···9295 return ownerDid, err
9396}
94979595-func GetPulls(e Execer, repoAt syntax.ATURI) ([]Pulls, error) {
9696- var pulls []Pulls
9898+func GetPulls(e Execer, repoAt syntax.ATURI) ([]Pull, error) {
9999+ var pulls []Pull
971009898- rows, err := e.Query(`select owner_did, pull_id, created, title, patch, open from pulls where repo_at = ? order by created desc`, repoAt)
101101+ 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)
99102 if err != nil {
100103 return nil, err
101104 }
102105 defer rows.Close()
103106104107 for rows.Next() {
105105- var pull Pulls
108108+ var pull Pull
106109 var createdAt string
107107- err := rows.Scan(&pull.OwnerDid, &pull.PullId, &createdAt, &pull.Title, &pull.Patch, &pull.Open)
110110+ err := rows.Scan(&pull.OwnerDid, &pull.PullId, &createdAt, &pull.Title, &pull.Open, &pull.TargetBranch, &pull.PullAt, &pull.Body, &pull.Patch, &pull.Rkey)
108111 if err != nil {
109112 return nil, err
110113 }
···125128 return pulls, nil
126129}
127130128128-func GetPull(e Execer, repoAt syntax.ATURI, pullId int) (*Pulls, error) {
129129- query := `select owner_did, created, title, patch, open from pulls where repo_at = ? and pull_id = ?`
131131+func GetPull(e Execer, repoAt syntax.ATURI, pullId int) (*Pull, error) {
132132+ query := `select owner_did, created, title, open, target_branch, pull_at, body, patch, rkey from pulls where repo_at = ? and pull_id = ?`
130133 row := e.QueryRow(query, repoAt, pullId)
131134132132- var pull Pulls
135135+ var pull Pull
133136 var createdAt string
134134- err := row.Scan(&pull.OwnerDid, &createdAt, &pull.Title, &pull.Patch, &pull.Open)
137137+ err := row.Scan(&pull.OwnerDid, &createdAt, &pull.Title, &pull.Open, &pull.TargetBranch, &pull.PullAt, &pull.Body, &pull.Patch, &pull.Rkey)
135138 if err != nil {
136139 return nil, err
137140 }
···145148 return &pull, nil
146149}
147150148148-func GetPullWithComments(e Execer, repoAt syntax.ATURI, pullId int) (*Pulls, []PullComments, error) {
149149- query := `select owner_did, pull_id, created, title, patch, open from pulls where repo_at = ? and pull_id = ?`
151151+func GetPullWithComments(e Execer, repoAt syntax.ATURI, pullId int) (*Pull, []PullComment, error) {
152152+ query := `select owner_did, pull_id, created, title, open, target_branch, pull_at, body, patch, rkey from pulls where repo_at = ? and pull_id = ?`
150153 row := e.QueryRow(query, repoAt, pullId)
151154152152- var pull Pulls
155155+ var pull Pull
153156 var createdAt string
154154- err := row.Scan(&pull.OwnerDid, &pull.PullId, &createdAt, &pull.Title, &pull.Patch, &pull.Open)
157157+ err := row.Scan(&pull.OwnerDid, &pull.PullId, &createdAt, &pull.Title, &pull.Open, &pull.TargetBranch, &pull.PullAt, &pull.Body, &pull.Patch, &pull.Rkey)
155158 if err != nil {
156159 return nil, nil, err
157160 }
···170173 return &pull, comments, nil
171174}
172175173173-func NewPullComment(e Execer, comment *PullComments) error {
176176+func NewPullComment(e Execer, comment *PullComment) error {
174177 query := `insert into pull_comments (owner_did, repo_at, comment_at, pull_id, comment_id, body) values (?, ?, ?, ?, ?, ?)`
175178 _, err := e.Exec(
176179 query,
···184187 return err
185188}
186189187187-func GetPullComments(e Execer, repoAt syntax.ATURI, pullId int) ([]PullComments, error) {
188188- var comments []PullComments
190190+func GetPullComments(e Execer, repoAt syntax.ATURI, pullId int) ([]PullComment, error) {
191191+ var comments []PullComment
189192190193 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)
191194 if err == sql.ErrNoRows {
192192- return []PullComments{}, nil
195195+ return []PullComment{}, nil
193196 }
194197 if err != nil {
195198 return nil, err
···197200 defer rows.Close()
198201199202 for rows.Next() {
200200- var comment PullComments
203203+ var comment PullComment
201204 var createdAt string
202205 err := rows.Scan(&comment.OwnerDid, &comment.PullId, &comment.CommentId, &comment.CommentAt, &comment.Body, &createdAt)
203206 if err != nil {