-6
appview/db/issues.go
-6
appview/db/issues.go
···
98
return issueAt, err
99
}
100
101
-
func GetIssueId(e Execer, repoAt syntax.ATURI) (int, error) {
102
-
var issueId int
103
-
err := e.QueryRow(`select next_issue_id from repo_issue_seqs where repo_at = ?`, repoAt).Scan(&issueId)
104
-
return issueId - 1, err
105
-
}
106
-
107
func GetIssueOwnerDid(e Execer, repoAt syntax.ATURI, issueId int) (string, error) {
108
var ownerDid string
109
err := e.QueryRow(`select owner_did from issues where repo_at = ? and issue_id = ?`, repoAt, issueId).Scan(&ownerDid)
+7
-13
appview/issues/issues.go
+7
-13
appview/issues/issues.go
···
703
return
704
}
705
706
-
err = db.NewIssue(tx, &db.Issue{
707
RepoAt: f.RepoAt,
708
Title: title,
709
Body: body,
710
OwnerDid: user.Did,
711
-
})
712
-
if err != nil {
713
-
log.Println("failed to create issue", err)
714
-
rp.pages.Notice(w, "issues", "Failed to create issue.")
715
-
return
716
}
717
-
718
-
issueId, err := db.GetIssueId(rp.db, f.RepoAt)
719
if err != nil {
720
-
log.Println("failed to get issue id", err)
721
rp.pages.Notice(w, "issues", "Failed to create issue.")
722
return
723
}
···
739
Title: title,
740
Body: &body,
741
Owner: user.Did,
742
-
IssueId: int64(issueId),
743
},
744
},
745
})
···
749
return
750
}
751
752
-
err = db.SetIssueAt(rp.db, f.RepoAt, issueId, resp.Uri)
753
if err != nil {
754
log.Println("failed to set issue at", err)
755
rp.pages.Notice(w, "issues", "Failed to create issue.")
···
760
err = rp.posthog.Enqueue(posthog.Capture{
761
DistinctId: user.Did,
762
Event: "new_issue",
763
-
Properties: posthog.Properties{"repo_at": f.RepoAt.String(), "issue_id": issueId},
764
})
765
if err != nil {
766
log.Println("failed to enqueue posthog event:", err)
767
}
768
}
769
770
-
rp.pages.HxLocation(w, fmt.Sprintf("/%s/issues/%d", f.OwnerSlashRepo(), issueId))
771
return
772
}
773
}
···
703
return
704
}
705
706
+
issue := &db.Issue{
707
RepoAt: f.RepoAt,
708
Title: title,
709
Body: body,
710
OwnerDid: user.Did,
711
}
712
+
err = db.NewIssue(tx, issue)
713
if err != nil {
714
+
log.Println("failed to create issue", err)
715
rp.pages.Notice(w, "issues", "Failed to create issue.")
716
return
717
}
···
733
Title: title,
734
Body: &body,
735
Owner: user.Did,
736
+
IssueId: int64(issue.IssueId),
737
},
738
},
739
})
···
743
return
744
}
745
746
+
err = db.SetIssueAt(rp.db, f.RepoAt, issue.IssueId, resp.Uri)
747
if err != nil {
748
log.Println("failed to set issue at", err)
749
rp.pages.Notice(w, "issues", "Failed to create issue.")
···
754
err = rp.posthog.Enqueue(posthog.Capture{
755
DistinctId: user.Did,
756
Event: "new_issue",
757
+
Properties: posthog.Properties{"repo_at": f.RepoAt.String(), "issue_id": issue.IssueId},
758
})
759
if err != nil {
760
log.Println("failed to enqueue posthog event:", err)
761
}
762
}
763
764
+
rp.pages.HxLocation(w, fmt.Sprintf("/%s/issues/%d", f.OwnerSlashRepo(), issue.IssueId))
765
return
766
}
767
}