Skip to content

Commit b65e954

Browse files
authored
FIX Pagination of ListAccessTokens and GetIssueWatchers (#10449)
* fix a pagination bug * fix pagination of ListAccessTokens
1 parent 0eeee9c commit b65e954

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

models/issue_watch.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,21 @@ func GetIssueWatchers(issueID int64, listOptions ListOptions) (IssueWatchList, e
8181
return getIssueWatchers(x, issueID, listOptions)
8282
}
8383

84-
func getIssueWatchers(e Engine, issueID int64, listOptions ListOptions) (watches IssueWatchList, err error) {
84+
func getIssueWatchers(e Engine, issueID int64, listOptions ListOptions) (IssueWatchList, error) {
8585
sess := e.
8686
Where("`issue_watch`.issue_id = ?", issueID).
8787
And("`issue_watch`.is_watching = ?", true).
8888
And("`user`.is_active = ?", true).
8989
And("`user`.prohibit_login = ?", false).
9090
Join("INNER", "`user`", "`user`.id = `issue_watch`.user_id")
9191

92-
if listOptions.Page == 0 {
92+
if listOptions.Page != 0 {
9393
sess = listOptions.setSessionPagination(sess)
94+
watches := make([]*IssueWatch, 0, listOptions.PageSize)
95+
return watches, sess.Find(&watches)
9496
}
95-
err = sess.Find(&watches)
96-
return
97+
watches := make([]*IssueWatch, 0, 8)
98+
return watches, sess.Find(&watches)
9799
}
98100

99101
func removeIssueWatchersByRepoID(e Engine, userID int64, repoID int64) error {

models/token.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func ListAccessTokens(uid int64, listOptions ListOptions) ([]*AccessToken, error
8383
Where("uid=?", uid).
8484
Desc("id")
8585

86-
if listOptions.Page == 0 {
86+
if listOptions.Page != 0 {
8787
sess = listOptions.setSessionPagination(sess)
8888

8989
tokens := make([]*AccessToken, 0, listOptions.PageSize)

0 commit comments

Comments
 (0)