Skip to content

Fix Pagination of ListAccessTokens and GetIssueWatchers #10449

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions models/issue_watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,21 @@ func GetIssueWatchers(issueID int64, listOptions ListOptions) (IssueWatchList, e
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.
Where("`issue_watch`.issue_id = ?", issueID).
And("`issue_watch`.is_watching = ?", true).
And("`user`.is_active = ?", true).
And("`user`.prohibit_login = ?", false).
Join("INNER", "`user`", "`user`.id = `issue_watch`.user_id")

if listOptions.Page == 0 {
if listOptions.Page != 0 {
sess = listOptions.setSessionPagination(sess)
watches := make([]*IssueWatch, 0, listOptions.PageSize)
return watches, sess.Find(&watches)
}
err = sess.Find(&watches)
return
watches := make([]*IssueWatch, 0, 8)
return watches, sess.Find(&watches)
}

func removeIssueWatchersByRepoID(e Engine, userID int64, repoID int64) error {
Expand Down
2 changes: 1 addition & 1 deletion models/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func ListAccessTokens(uid int64, listOptions ListOptions) ([]*AccessToken, error
Where("uid=?", uid).
Desc("id")

if listOptions.Page == 0 {
if listOptions.Page != 0 {
sess = listOptions.setSessionPagination(sess)

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