Skip to content

Commit 941acdf

Browse files
jolheiserneurosnap
authored andcommitted
fix patchset count for specific user
Signed-off-by: jolheiser <[email protected]>
1 parent 56c1c13 commit 941acdf

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

pr.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ type GitPatchRequest interface {
3838
GetPatchRequestByID(prID int64) (*PatchRequest, error)
3939
GetPatchRequests() ([]*PatchRequest, error)
4040
GetPatchRequestsByRepoID(repoID int64) ([]*PatchRequest, error)
41+
GetPatchRequestsByPubkey(pubkey string) ([]*PatchRequest, error)
4142
GetPatchsetsByPrID(prID int64) ([]*Patchset, error)
4243
GetPatchsetByID(patchsetID int64) (*Patchset, error)
4344
GetLatestPatchsetByPrID(prID int64) (*Patchset, error)
@@ -271,6 +272,16 @@ func (cmd PrCmd) GetPatchRequestsByRepoID(repoID int64) ([]*PatchRequest, error)
271272
return prs, err
272273
}
273274

275+
func (cmd PrCmd) GetPatchRequestsByPubkey(pubkey string) ([]*PatchRequest, error) {
276+
prs := []*PatchRequest{}
277+
err := cmd.Backend.DB.Select(
278+
&prs,
279+
"SELECT pr.* FROM patch_requests pr, app_users au WHERE pr.user_id=au.id AND au.pubkey=? ORDER BY id DESC",
280+
pubkey,
281+
)
282+
return prs, err
283+
}
284+
274285
func (cmd PrCmd) GetPatchRequestByID(prID int64) (*PatchRequest, error) {
275286
pr := PatchRequest{}
276287
err := cmd.Backend.DB.Get(

web.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ func userDetailHandler(w http.ResponseWriter, r *http.Request) {
390390
}
391391
isAdmin := web.Backend.IsAdmin(pk)
392392

393-
prs, err := web.Pr.GetPatchRequests()
393+
prs, err := web.Pr.GetPatchRequestsByPubkey(user.Pubkey)
394394
if err != nil {
395395
web.Logger.Error("cannot get prs", "err", err)
396396
w.WriteHeader(http.StatusInternalServerError)

0 commit comments

Comments
 (0)