Skip to content

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

Closed
wants to merge 2 commits into from

Conversation

lunny
Copy link
Member

@lunny lunny commented Feb 1, 2023

This adds pagination support to search results, next PR will include template changes to allow for UI to utilize this pagination.

@techknowlogick techknowlogick added this to the 1.20.0 milestone Feb 25, 2023
@techknowlogick techknowlogick added type/enhancement An improvement of existing functionality type/refactoring Existing code has been cleaned up. There should be no new functionality. labels Feb 25, 2023
@techknowlogick techknowlogick marked this pull request as ready for review February 25, 2023 04:18
@GiteaBot GiteaBot added the lgtm/need 1 This PR needs approval from one additional maintainer to be merged. label Feb 25, 2023
Comment on lines +192 to +199
// 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
}
Copy link
Member

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.

Copy link
Member Author

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 {
Copy link
Member

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?

Comment on lines +485 to +492
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
}
Copy link
Member

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,
Copy link
Member

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 {
Copy link
Member

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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above

@wxiaoguang
Copy link
Contributor

Stale?

@lunny
Copy link
Member Author

lunny commented Apr 30, 2023

After finished this PR, I realize we should not support pagination for a search engine. The next page maybe better.

@lunny lunny closed this May 16, 2023
@GiteaBot GiteaBot removed this from the 1.20.0 milestone May 16, 2023
@lunny lunny deleted the lunny/search_issues_pagination branch May 16, 2023 03:16
@techknowlogick
Copy link
Member

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.

@lunny
Copy link
Member Author

lunny commented May 16, 2023

I'm writing a new PR which will replace this one and try to fix #24662

@go-gitea go-gitea locked as resolved and limited conversation to collaborators Aug 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/need 1 This PR needs approval from one additional maintainer to be merged. type/enhancement An improvement of existing functionality type/refactoring Existing code has been cleaned up. There should be no new functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants