mirror of
https://github.com/go-gitea/gitea.git
synced 2024-11-04 08:17:24 -05:00
Increase default item listing size ISSUE_PAGING_NUM
to 20 (#20547)
* increase default page sizes to 20 * adjust docs to reflect that the setting is used all over the place * fix tests Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
parent
61aafb9c7d
commit
279e4e235c
@ -1083,7 +1083,7 @@ ROUTER = console
|
||||
;EXPLORE_PAGING_NUM = 20
|
||||
;;
|
||||
;; Number of issues that are displayed on one page
|
||||
;ISSUE_PAGING_NUM = 10
|
||||
;ISSUE_PAGING_NUM = 20
|
||||
;;
|
||||
;; Number of maximum commits displayed in one activity feed
|
||||
;FEED_MAX_COMMIT_NUM = 5
|
||||
|
@ -172,7 +172,7 @@ The following configuration set `Content-Type: application/vnd.android.package-a
|
||||
## UI (`ui`)
|
||||
|
||||
- `EXPLORE_PAGING_NUM`: **20**: Number of repositories that are shown in one explore page.
|
||||
- `ISSUE_PAGING_NUM`: **10**: Number of issues that are shown in one page (for all pages that list issues).
|
||||
- `ISSUE_PAGING_NUM`: **20**: Number of issues that are shown in one page (for all pages that list issues, milestones, projects).
|
||||
- `MEMBERS_PAGING_NUM`: **20**: Number of members that are shown in organization members.
|
||||
- `FEED_MAX_COMMIT_NUM`: **5**: Number of maximum commits shown in one activity feed.
|
||||
- `FEED_PAGING_NUM`: **20**: Number of items that are displayed in home feed.
|
||||
|
@ -16,6 +16,7 @@ import (
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@ -171,19 +172,21 @@ func TestAPISearchIssues(t *testing.T) {
|
||||
|
||||
token := getUserToken(t, "user2")
|
||||
|
||||
link, _ := url.Parse("/api/v1/repos/issues/search")
|
||||
req := NewRequest(t, "GET", link.String()+"?token="+token)
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
var apiIssues []*api.Issue
|
||||
DecodeJSON(t, resp, &apiIssues)
|
||||
assert.Len(t, apiIssues, 10)
|
||||
// as this API was used in the frontend, it uses UI page size
|
||||
expectedIssueCount := 15 // from the fixtures
|
||||
if expectedIssueCount > setting.UI.IssuePagingNum {
|
||||
expectedIssueCount = setting.UI.IssuePagingNum
|
||||
}
|
||||
|
||||
link, _ := url.Parse("/api/v1/repos/issues/search")
|
||||
query := url.Values{"token": {getUserToken(t, "user1")}}
|
||||
var apiIssues []*api.Issue
|
||||
|
||||
query := url.Values{"token": {token}}
|
||||
link.RawQuery = query.Encode()
|
||||
req = NewRequest(t, "GET", link.String())
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
req := NewRequest(t, "GET", link.String())
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
DecodeJSON(t, resp, &apiIssues)
|
||||
assert.Len(t, apiIssues, 10)
|
||||
assert.Len(t, apiIssues, expectedIssueCount)
|
||||
|
||||
since := "2000-01-01T00%3A50%3A01%2B00%3A00" // 946687801
|
||||
before := time.Unix(999307200, 0).Format(time.RFC3339)
|
||||
@ -211,14 +214,15 @@ func TestAPISearchIssues(t *testing.T) {
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
DecodeJSON(t, resp, &apiIssues)
|
||||
assert.EqualValues(t, "17", resp.Header().Get("X-Total-Count"))
|
||||
assert.Len(t, apiIssues, 10) // there are more but 10 is page item limit
|
||||
assert.Len(t, apiIssues, 17)
|
||||
|
||||
query.Add("limit", "20")
|
||||
query.Add("limit", "10")
|
||||
link.RawQuery = query.Encode()
|
||||
req = NewRequest(t, "GET", link.String())
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
DecodeJSON(t, resp, &apiIssues)
|
||||
assert.Len(t, apiIssues, 17)
|
||||
assert.EqualValues(t, "17", resp.Header().Get("X-Total-Count"))
|
||||
assert.Len(t, apiIssues, 10)
|
||||
|
||||
query = url.Values{"assigned": {"true"}, "state": {"all"}, "token": {token}}
|
||||
link.RawQuery = query.Encode()
|
||||
@ -266,23 +270,21 @@ func TestAPISearchIssues(t *testing.T) {
|
||||
func TestAPISearchIssuesWithLabels(t *testing.T) {
|
||||
defer prepareTestEnv(t)()
|
||||
|
||||
token := getUserToken(t, "user1")
|
||||
// as this API was used in the frontend, it uses UI page size
|
||||
expectedIssueCount := 15 // from the fixtures
|
||||
if expectedIssueCount > setting.UI.IssuePagingNum {
|
||||
expectedIssueCount = setting.UI.IssuePagingNum
|
||||
}
|
||||
|
||||
link, _ := url.Parse("/api/v1/repos/issues/search")
|
||||
req := NewRequest(t, "GET", link.String()+"?token="+token)
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
query := url.Values{"token": {getUserToken(t, "user1")}}
|
||||
var apiIssues []*api.Issue
|
||||
DecodeJSON(t, resp, &apiIssues)
|
||||
|
||||
assert.Len(t, apiIssues, 10)
|
||||
|
||||
query := url.Values{}
|
||||
query.Add("token", token)
|
||||
link.RawQuery = query.Encode()
|
||||
req = NewRequest(t, "GET", link.String())
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
req := NewRequest(t, "GET", link.String())
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
DecodeJSON(t, resp, &apiIssues)
|
||||
assert.Len(t, apiIssues, 10)
|
||||
assert.Len(t, apiIssues, expectedIssueCount)
|
||||
|
||||
query.Add("labels", "label1")
|
||||
link.RawQuery = query.Encode()
|
||||
|
@ -356,17 +356,17 @@ func TestSearchIssues(t *testing.T) {
|
||||
|
||||
session := loginUser(t, "user2")
|
||||
|
||||
expectedIssueCount := 15 // from the fixtures
|
||||
if expectedIssueCount > setting.UI.IssuePagingNum {
|
||||
expectedIssueCount = setting.UI.IssuePagingNum
|
||||
}
|
||||
|
||||
link, _ := url.Parse("/issues/search")
|
||||
req := NewRequest(t, "GET", link.String())
|
||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||
var apiIssues []*api.Issue
|
||||
DecodeJSON(t, resp, &apiIssues)
|
||||
assert.Len(t, apiIssues, 10)
|
||||
|
||||
req = NewRequest(t, "GET", link.String())
|
||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||
DecodeJSON(t, resp, &apiIssues)
|
||||
assert.Len(t, apiIssues, 10)
|
||||
assert.Len(t, apiIssues, expectedIssueCount)
|
||||
|
||||
since := "2000-01-01T00%3A50%3A01%2B00%3A00" // 946687801
|
||||
before := time.Unix(999307200, 0).Format(time.RFC3339)
|
||||
@ -394,14 +394,15 @@ func TestSearchIssues(t *testing.T) {
|
||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||
DecodeJSON(t, resp, &apiIssues)
|
||||
assert.EqualValues(t, "17", resp.Header().Get("X-Total-Count"))
|
||||
assert.Len(t, apiIssues, 10) // there are more but 10 is page item limit
|
||||
assert.Len(t, apiIssues, 17)
|
||||
|
||||
query.Add("limit", "20")
|
||||
query.Add("limit", "5")
|
||||
link.RawQuery = query.Encode()
|
||||
req = NewRequest(t, "GET", link.String())
|
||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||
DecodeJSON(t, resp, &apiIssues)
|
||||
assert.Len(t, apiIssues, 17)
|
||||
assert.EqualValues(t, "17", resp.Header().Get("X-Total-Count"))
|
||||
assert.Len(t, apiIssues, 5)
|
||||
|
||||
query = url.Values{"assigned": {"true"}, "state": {"all"}}
|
||||
link.RawQuery = query.Encode()
|
||||
@ -449,29 +450,26 @@ func TestSearchIssues(t *testing.T) {
|
||||
func TestSearchIssuesWithLabels(t *testing.T) {
|
||||
defer prepareTestEnv(t)()
|
||||
|
||||
token := getUserToken(t, "user1")
|
||||
|
||||
link, _ := url.Parse("/api/v1/repos/issues/search?token=" + token)
|
||||
req := NewRequest(t, "GET", link.String())
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
var apiIssues []*api.Issue
|
||||
DecodeJSON(t, resp, &apiIssues)
|
||||
|
||||
assert.Len(t, apiIssues, 10)
|
||||
|
||||
query := url.Values{
|
||||
"token": []string{token},
|
||||
expectedIssueCount := 15 // from the fixtures
|
||||
if expectedIssueCount > setting.UI.IssuePagingNum {
|
||||
expectedIssueCount = setting.UI.IssuePagingNum
|
||||
}
|
||||
|
||||
session := loginUser(t, "user1")
|
||||
link, _ := url.Parse("/issues/search")
|
||||
query := url.Values{}
|
||||
var apiIssues []*api.Issue
|
||||
|
||||
link.RawQuery = query.Encode()
|
||||
req = NewRequest(t, "GET", link.String())
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
req := NewRequest(t, "GET", link.String())
|
||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||
DecodeJSON(t, resp, &apiIssues)
|
||||
assert.Len(t, apiIssues, 10)
|
||||
assert.Len(t, apiIssues, expectedIssueCount)
|
||||
|
||||
query.Add("labels", "label1")
|
||||
link.RawQuery = query.Encode()
|
||||
req = NewRequest(t, "GET", link.String())
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||
DecodeJSON(t, resp, &apiIssues)
|
||||
assert.Len(t, apiIssues, 2)
|
||||
|
||||
@ -479,7 +477,7 @@ func TestSearchIssuesWithLabels(t *testing.T) {
|
||||
query.Set("labels", "label1,label2")
|
||||
link.RawQuery = query.Encode()
|
||||
req = NewRequest(t, "GET", link.String())
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||
DecodeJSON(t, resp, &apiIssues)
|
||||
assert.Len(t, apiIssues, 2)
|
||||
|
||||
@ -487,7 +485,7 @@ func TestSearchIssuesWithLabels(t *testing.T) {
|
||||
query.Set("labels", "orglabel4")
|
||||
link.RawQuery = query.Encode()
|
||||
req = NewRequest(t, "GET", link.String())
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||
DecodeJSON(t, resp, &apiIssues)
|
||||
assert.Len(t, apiIssues, 1)
|
||||
|
||||
@ -496,7 +494,7 @@ func TestSearchIssuesWithLabels(t *testing.T) {
|
||||
query.Add("state", "all")
|
||||
link.RawQuery = query.Encode()
|
||||
req = NewRequest(t, "GET", link.String())
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||
DecodeJSON(t, resp, &apiIssues)
|
||||
assert.Len(t, apiIssues, 2)
|
||||
|
||||
@ -504,7 +502,7 @@ func TestSearchIssuesWithLabels(t *testing.T) {
|
||||
query.Set("labels", "label1,orglabel4")
|
||||
link.RawQuery = query.Encode()
|
||||
req = NewRequest(t, "GET", link.String())
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||
DecodeJSON(t, resp, &apiIssues)
|
||||
assert.Len(t, apiIssues, 2)
|
||||
}
|
||||
|
@ -262,8 +262,8 @@ var (
|
||||
}{
|
||||
ExplorePagingNum: 20,
|
||||
SitemapPagingNum: 20,
|
||||
IssuePagingNum: 10,
|
||||
RepoSearchPagingNum: 10,
|
||||
IssuePagingNum: 20,
|
||||
RepoSearchPagingNum: 20,
|
||||
MembersPagingNum: 20,
|
||||
FeedMaxCommitNum: 5,
|
||||
FeedPagingNum: 20,
|
||||
|
Loading…
Reference in New Issue
Block a user