Mirror of @tangled.org/core. Running on a Raspberry Pi Zero 2 (Please be gentle).
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

appview: db: avoid setting PullAt

authored by

Akshay and committed by
Tangled
79ed2d0a 9b359e68

+14 -18
+11 -14
appview/db/pulls.go
··· 10 10 11 11 "github.com/bluekeyes/go-gitdiff/gitdiff" 12 12 "github.com/bluesky-social/indigo/atproto/syntax" 13 + tangled "tangled.sh/tangled.sh/core/api/tangled" 13 14 "tangled.sh/tangled.sh/core/patchutil" 14 15 "tangled.sh/tangled.sh/core/types" 15 16 ) ··· 55 54 RepoAt syntax.ATURI 56 55 OwnerDid string 57 56 Rkey string 58 - PullAt syntax.ATURI 59 57 60 58 // content 61 59 Title string ··· 118 118 func (p *Pull) LatestPatch() string { 119 119 latestSubmission := p.Submissions[p.LastRoundNumber()] 120 120 return latestSubmission.Patch 121 + } 122 + 123 + func (p *Pull) PullAt() syntax.ATURI { 124 + return syntax.ATURI(fmt.Sprintf("at://%s/%s/%s", p.OwnerDid, tangled.RepoPullNSID, p.Rkey)) 121 125 } 122 126 123 127 func (p *Pull) LastRoundNumber() int { ··· 302 298 return nil 303 299 } 304 300 305 - func SetPullAt(e Execer, repoAt syntax.ATURI, pullId int, pullAt string) error { 306 - _, err := e.Exec(`update pulls set pull_at = ? where repo_at = ? and pull_id = ?`, pullAt, repoAt, pullId) 307 - return err 308 - } 309 - 310 - func GetPullAt(e Execer, repoAt syntax.ATURI, pullId int) (string, error) { 311 - var pullAt string 312 - err := e.QueryRow(`select pull_at from pulls where repo_at = ? and pull_id = ?`, repoAt, pullId).Scan(&pullAt) 313 - return pullAt, err 301 + func GetPullAt(e Execer, repoAt syntax.ATURI, pullId int) (syntax.ATURI, error) { 302 + pull, err := GetPull(e, repoAt, pullId) 303 + if err != nil { 304 + return "", err 305 + } 306 + return pull.PullAt(), err 314 307 } 315 308 316 309 func NextPullId(e Execer, repoAt syntax.ATURI) (int, error) { ··· 327 326 title, 328 327 state, 329 328 target_branch, 330 - pull_at, 331 329 body, 332 330 rkey, 333 331 source_branch, ··· 351 351 &pull.Title, 352 352 &pull.State, 353 353 &pull.TargetBranch, 354 - &pull.PullAt, 355 354 &pull.Body, 356 355 &pull.Rkey, 357 356 &sourceBranch, ··· 486 487 title, 487 488 state, 488 489 target_branch, 489 - pull_at, 490 490 repo_at, 491 491 body, 492 492 rkey, ··· 508 510 &pull.Title, 509 511 &pull.State, 510 512 &pull.TargetBranch, 511 - &pull.PullAt, 512 513 &pull.RepoAt, 513 514 &pull.Body, 514 515 &pull.Rkey,
+3 -4
appview/state/pull.go
··· 528 528 Record: &lexutil.LexiconTypeDecoder{ 529 529 Val: &tangled.RepoPullComment{ 530 530 Repo: &atUri, 531 - Pull: pullAt, 531 + Pull: string(pullAt), 532 532 Owner: &ownerDid, 533 533 Body: &body, 534 534 CreatedAt: &createdAt, ··· 879 879 return 880 880 } 881 881 882 - atResp, err := comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 882 + _, err = comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 883 883 Collection: tangled.RepoPullNSID, 884 884 Repo: user.Did, 885 885 Rkey: rkey, ··· 895 895 }, 896 896 }) 897 897 898 - err = db.SetPullAt(s.db, f.RepoAt, pullId, atResp.Uri) 899 898 if err != nil { 900 - log.Println("failed to get pull id", err) 899 + log.Println("failed to create pull request", err) 901 900 s.pages.Notice(w, "pull", "Failed to create pull request. Try again later.") 902 901 return 903 902 }