From 279e4e235cd28b570e2947cc8c397280e9250440 Mon Sep 17 00:00:00 2001 From: Norwin Date: Sat, 6 Aug 2022 12:43:40 +0200 Subject: [PATCH] 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 Co-authored-by: wxiaoguang --- custom/conf/app.example.ini | 2 +- .../doc/advanced/config-cheat-sheet.en-us.md | 2 +- integrations/api_issue_test.go | 50 +++++++++-------- integrations/issue_test.go | 56 +++++++++---------- modules/setting/setting.go | 4 +- 5 files changed, 57 insertions(+), 57 deletions(-) diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index feff190f8..83b3048bc 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -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 diff --git a/docs/content/doc/advanced/config-cheat-sheet.en-us.md b/docs/content/doc/advanced/config-cheat-sheet.en-us.md index fef320184..6b050e12b 100644 --- a/docs/content/doc/advanced/config-cheat-sheet.en-us.md +++ b/docs/content/doc/advanced/config-cheat-sheet.en-us.md @@ -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. diff --git a/integrations/api_issue_test.go b/integrations/api_issue_test.go index 5c802e8d2..bb4e2f0c7 100644 --- a/integrations/api_issue_test.go +++ b/integrations/api_issue_test.go @@ -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() diff --git a/integrations/issue_test.go b/integrations/issue_test.go index 7d30d657f..e1d3b1b21 100644 --- a/integrations/issue_test.go +++ b/integrations/issue_test.go @@ -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) } diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 23e3280dc..465dc75ca 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -262,8 +262,8 @@ var ( }{ ExplorePagingNum: 20, SitemapPagingNum: 20, - IssuePagingNum: 10, - RepoSearchPagingNum: 10, + IssuePagingNum: 20, + RepoSearchPagingNum: 20, MembersPagingNum: 20, FeedMaxCommitNum: 5, FeedPagingNum: 20,