FIX Pagination of ListAccessTokens and GetIssueWatchers (#10449)
* fix a pagination bug * fix pagination of ListAccessTokens
This commit is contained in:
parent
0eeee9c721
commit
b65e954f73
2 changed files with 7 additions and 5 deletions
|
@ -81,7 +81,7 @@ func GetIssueWatchers(issueID int64, listOptions ListOptions) (IssueWatchList, e
|
||||||
return getIssueWatchers(x, issueID, listOptions)
|
return getIssueWatchers(x, issueID, listOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getIssueWatchers(e Engine, issueID int64, listOptions ListOptions) (watches IssueWatchList, err error) {
|
func getIssueWatchers(e Engine, issueID int64, listOptions ListOptions) (IssueWatchList, error) {
|
||||||
sess := e.
|
sess := e.
|
||||||
Where("`issue_watch`.issue_id = ?", issueID).
|
Where("`issue_watch`.issue_id = ?", issueID).
|
||||||
And("`issue_watch`.is_watching = ?", true).
|
And("`issue_watch`.is_watching = ?", true).
|
||||||
|
@ -89,11 +89,13 @@ func getIssueWatchers(e Engine, issueID int64, listOptions ListOptions) (watches
|
||||||
And("`user`.prohibit_login = ?", false).
|
And("`user`.prohibit_login = ?", false).
|
||||||
Join("INNER", "`user`", "`user`.id = `issue_watch`.user_id")
|
Join("INNER", "`user`", "`user`.id = `issue_watch`.user_id")
|
||||||
|
|
||||||
if listOptions.Page == 0 {
|
if listOptions.Page != 0 {
|
||||||
sess = listOptions.setSessionPagination(sess)
|
sess = listOptions.setSessionPagination(sess)
|
||||||
|
watches := make([]*IssueWatch, 0, listOptions.PageSize)
|
||||||
|
return watches, sess.Find(&watches)
|
||||||
}
|
}
|
||||||
err = sess.Find(&watches)
|
watches := make([]*IssueWatch, 0, 8)
|
||||||
return
|
return watches, sess.Find(&watches)
|
||||||
}
|
}
|
||||||
|
|
||||||
func removeIssueWatchersByRepoID(e Engine, userID int64, repoID int64) error {
|
func removeIssueWatchersByRepoID(e Engine, userID int64, repoID int64) error {
|
||||||
|
|
|
@ -83,7 +83,7 @@ func ListAccessTokens(uid int64, listOptions ListOptions) ([]*AccessToken, error
|
||||||
Where("uid=?", uid).
|
Where("uid=?", uid).
|
||||||
Desc("id")
|
Desc("id")
|
||||||
|
|
||||||
if listOptions.Page == 0 {
|
if listOptions.Page != 0 {
|
||||||
sess = listOptions.setSessionPagination(sess)
|
sess = listOptions.setSessionPagination(sess)
|
||||||
|
|
||||||
tokens := make([]*AccessToken, 0, listOptions.PageSize)
|
tokens := make([]*AccessToken, 0, listOptions.PageSize)
|
||||||
|
|
Reference in a new issue