- commit
- 941acdf
- parent
- 56c1c13
- author
- jolheiser
- date
- 2025-04-07 19:01:41 -0400 EDT
fix patchset count for specific user Signed-off-by: jolheiser <git@jolheiser.com>
M
pr.go
+11,
-0
1@@ -38,6 +38,7 @@ type GitPatchRequest interface {
2 GetPatchRequestByID(prID int64) (*PatchRequest, error)
3 GetPatchRequests() ([]*PatchRequest, error)
4 GetPatchRequestsByRepoID(repoID int64) ([]*PatchRequest, error)
5+ GetPatchRequestsByPubkey(pubkey string) ([]*PatchRequest, error)
6 GetPatchsetsByPrID(prID int64) ([]*Patchset, error)
7 GetPatchsetByID(patchsetID int64) (*Patchset, error)
8 GetLatestPatchsetByPrID(prID int64) (*Patchset, error)
9@@ -271,6 +272,16 @@ func (cmd PrCmd) GetPatchRequestsByRepoID(repoID int64) ([]*PatchRequest, error)
10 return prs, err
11 }
12
13+func (cmd PrCmd) GetPatchRequestsByPubkey(pubkey string) ([]*PatchRequest, error) {
14+ prs := []*PatchRequest{}
15+ err := cmd.Backend.DB.Select(
16+ &prs,
17+ "SELECT pr.* FROM patch_requests pr, app_users au WHERE pr.user_id=au.id AND au.pubkey=? ORDER BY id DESC",
18+ pubkey,
19+ )
20+ return prs, err
21+}
22+
23 func (cmd PrCmd) GetPatchRequestByID(prID int64) (*PatchRequest, error) {
24 pr := PatchRequest{}
25 err := cmd.Backend.DB.Get(
M
web.go
+1,
-1
1@@ -390,7 +390,7 @@ func userDetailHandler(w http.ResponseWriter, r *http.Request) {
2 }
3 isAdmin := web.Backend.IsAdmin(pk)
4
5- prs, err := web.Pr.GetPatchRequests()
6+ prs, err := web.Pr.GetPatchRequestsByPubkey(user.Pubkey)
7 if err != nil {
8 web.Logger.Error("cannot get prs", "err", err)
9 w.WriteHeader(http.StatusInternalServerError)