···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 int1212+ OwnerDid string1313+ RepoAt syntax.ATURI1414+ PullAt syntax.ATURI1515+ TargetBranch string1616+ Patch string1717+ PullId int1818+ Title string1919+ Body string2020+ Open int2121+ Created time.Time2222+ Rkey string2023}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 int2727+ OwnerDid string2828+ PullId int2929+ RepoAt string3030+ CommentId int3131+ CommentAt string3232+ Body string3333+ Created time.Time3134}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(`···5855 pull.PullId = nextId59566057 _, err = tx.Exec(`6161- insert into pulls (repo_at, owner_did, pull_id, title, patch)6262- values (?, ?, ?, ?, ?)6363- `, pull.RepoAt, pull.OwnerDid, pull.PullId, pull.Title, pull.Patch)5858+ insert into pulls (repo_at, owner_did, pull_id, title, target_branch, body, patch, rkey)5959+ values (?, ?, ?, ?, ?, ?, ?, ?)6060+ `, pull.RepoAt, pull.OwnerDid, pull.PullId, pull.Title, pull.TargetBranch, pull.Body, pull.Patch, pull.Rkey)6461 if err != nil {6562 return err6663 }···7370}74717572func SetPullAt(e Execer, repoAt syntax.ATURI, pullId int, pullAt string) error {7676- _, err := e.Exec(`update pulls set patch_at = ? where repo_at = ? and pull_id = ?`, pullAt, repoAt, pullId)7373+ _, err := e.Exec(`update pulls set pull_at = ? where repo_at = ? and pull_id = ?`, pullAt, repoAt, pullId)7774 return err7875}79768077func GetPullAt(e Execer, repoAt syntax.ATURI, pullId int) (string, error) {8178 var pullAt string8282- err := e.QueryRow(`select patch_at from pulls where repo_at = ? and pull_id = ?`, repoAt, pullId).Scan(&pullAt)7979+ err := e.QueryRow(`select pull_at from pulls where repo_at = ? and pull_id = ?`, repoAt, pullId).Scan(&pullAt)8380 return pullAt, err8481}8582···9592 return ownerDid, err9693}97949898-func GetPulls(e Execer, repoAt syntax.ATURI) ([]Pulls, error) {9999- var pulls []Pulls9595+func GetPulls(e Execer, repoAt syntax.ATURI) ([]Pull, error) {9696+ var pulls []Pull10097101101- rows, err := e.Query(`select owner_did, pull_id, created, title, patch, open from pulls where repo_at = ? order by created desc`, repoAt)9898+ 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)10299 if err != nil {103100 return nil, err104101 }105102 defer rows.Close()106103107104 for rows.Next() {108108- var pull Pulls105105+ var pull Pull109106 var createdAt string110110- err := rows.Scan(&pull.OwnerDid, &pull.PullId, &createdAt, &pull.Title, &pull.Patch, &pull.Open)107107+ err := rows.Scan(&pull.OwnerDid, &pull.PullId, &createdAt, &pull.Title, &pull.Open, &pull.TargetBranch, &pull.PullAt, &pull.Body, &pull.Patch, &pull.Rkey)111108 if err != nil {112109 return nil, err113110 }···128125 return pulls, nil129126}130127131131-func GetPull(e Execer, repoAt syntax.ATURI, pullId int) (*Pulls, error) {132132- query := `select owner_did, created, title, patch, open from pulls where repo_at = ? and pull_id = ?`128128+func GetPull(e Execer, repoAt syntax.ATURI, pullId int) (*Pull, error) {129129+ query := `select owner_did, created, title, open, target_branch, pull_at, body, patch, rkey from pulls where repo_at = ? and pull_id = ?`133130 row := e.QueryRow(query, repoAt, pullId)134131135135- var pull Pulls132132+ var pull Pull136133 var createdAt string137137- err := row.Scan(&pull.OwnerDid, &createdAt, &pull.Title, &pull.Patch, &pull.Open)134134+ err := row.Scan(&pull.OwnerDid, &createdAt, &pull.Title, &pull.Open, &pull.TargetBranch, &pull.PullAt, &pull.Body, &pull.Patch, &pull.Rkey)138135 if err != nil {139136 return nil, err140137 }···148145 return &pull, nil149146}150147151151-func GetPullWithComments(e Execer, repoAt syntax.ATURI, pullId int) (*Pulls, []PullComments, error) {152152- query := `select owner_did, pull_id, created, title, patch, open from pulls where repo_at = ? and pull_id = ?`148148+func GetPullWithComments(e Execer, repoAt syntax.ATURI, pullId int) (*Pull, []PullComment, error) {149149+ query := `select owner_did, pull_id, created, title, open, target_branch, pull_at, body, patch, rkey from pulls where repo_at = ? and pull_id = ?`153150 row := e.QueryRow(query, repoAt, pullId)154151155155- var pull Pulls152152+ var pull Pull156153 var createdAt string157157- err := row.Scan(&pull.OwnerDid, &pull.PullId, &createdAt, &pull.Title, &pull.Patch, &pull.Open)154154+ err := row.Scan(&pull.OwnerDid, &pull.PullId, &createdAt, &pull.Title, &pull.Open, &pull.TargetBranch, &pull.PullAt, &pull.Body, &pull.Patch, &pull.Rkey)158155 if err != nil {159156 return nil, nil, err160157 }···173170 return &pull, comments, nil174171}175172176176-func NewPullComment(e Execer, comment *PullComments) error {173173+func NewPullComment(e Execer, comment *PullComment) error {177174 query := `insert into pull_comments (owner_did, repo_at, comment_at, pull_id, comment_id, body) values (?, ?, ?, ?, ?, ?)`178175 _, err := e.Exec(179176 query,···187184 return err188185}189186190190-func GetPullComments(e Execer, repoAt syntax.ATURI, pullId int) ([]PullComments, error) {191191- var comments []PullComments187187+func GetPullComments(e Execer, repoAt syntax.ATURI, pullId int) ([]PullComment, error) {188188+ var comments []PullComment192189193190 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)194191 if err == sql.ErrNoRows {195195- return []PullComments{}, nil192192+ return []PullComment{}, nil196193 }197194 if err != nil {198195 return nil, err···200197 defer rows.Close()201198202199 for rows.Next() {203203- var comment PullComments200200+ var comment PullComment204201 var createdAt string205202 err := rows.Scan(&comment.OwnerDid, &comment.PullId, &comment.CommentId, &comment.CommentAt, &comment.Body, &createdAt)206203 if err != nil {