-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
support search issues pagination #22704
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
Conversation
// this api is also used in UI, | ||
// so the default limit is set to fit UI needs | ||
limit := ctx.FormInt("limit") | ||
if limit == 0 { | ||
limit = setting.UI.IssuePagingNum | ||
} else if limit > setting.API.MaxResponseItems { | ||
limit = setting.API.MaxResponseItems | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤨
Sounds like a bug report waiting to happen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These lines just moved from line 222 - 230
if filteredCount, err = issues_model.CountIssues(ctx, issuesOpt); err != nil { | ||
ctx.Error(http.StatusInternalServerError, "CountIssues", err) | ||
return | ||
if filteredCount == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Under what circumstances is filteredCount
0
and why should we return the total number of issues then?
Can't we just delete this whole branch now?
if filteredCount == 0 { | ||
issuesOpt.ListOptions = db.ListOptions{ | ||
Page: -1, | ||
} | ||
if filteredCount, err = issues_model.CountIssues(ctx, issuesOpt); err != nil { | ||
ctx.Error(http.StatusInternalServerError, "CountIssues", err) | ||
return | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above
@@ -2341,13 +2342,22 @@ func SearchIssues(ctx *context.Context) { | |||
var issues []*issues_model.Issue | |||
var filteredCount int64 | |||
|
|||
// this api is also used in UI, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is no longer an API
if filteredCount, err = issues_model.CountIssues(ctx, issuesOpt); err != nil { | ||
ctx.Error(http.StatusInternalServerError, "CountIssues", err.Error()) | ||
return | ||
if filteredCount == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above
if filteredCount, err = issues_model.CountIssues(ctx, issuesOpt); err != nil { | ||
ctx.Error(http.StatusInternalServerError, err.Error()) | ||
return | ||
if filteredCount == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above
Stale? |
After finished this PR, I realize we should not support pagination for a search engine. The next page maybe better. |
For anyone coming to this PR in the future as in the linked issue, this PR is not suitable for pagination due to other issues. |
I'm writing a new PR which will replace this one and try to fix #24662 |
This adds pagination support to search results, next PR will include template changes to allow for UI to utilize this pagination.