diff --git a/models/issues/issue_stats.go b/models/issues/issue_stats.go index dc634cf00e..fdc06b05d1 100644 --- a/models/issues/issue_stats.go +++ b/models/issues/issue_stats.go @@ -15,13 +15,13 @@ import ( // IssueStats represents issue statistic information. type IssueStats struct { - OpenCount, ClosedCount int64 - YourRepositoriesCount int64 - AssignCount int64 - CreateCount int64 - MentionCount int64 - ReviewRequestedCount int64 - ReviewedCount int64 + OpenCount, ClosedCount, AllCount int64 + YourRepositoriesCount int64 + AssignCount int64 + CreateCount int64 + MentionCount int64 + ReviewRequestedCount int64 + ReviewedCount int64 } // Filter modes. @@ -104,6 +104,7 @@ func GetIssueStats(ctx context.Context, opts *IssuesOptions) (*IssueStats, error } accum.OpenCount += stats.OpenCount accum.ClosedCount += stats.ClosedCount + accum.AllCount += stats.AllCount accum.YourRepositoriesCount += stats.YourRepositoriesCount accum.AssignCount += stats.AssignCount accum.CreateCount += stats.CreateCount @@ -131,7 +132,13 @@ func getIssueStatsChunk(ctx context.Context, opts *IssuesOptions, issueIDs []int stats.ClosedCount, err = applyIssuesOptions(sess, opts, issueIDs). And("issue.is_closed = ?", true). Count(new(Issue)) - return stats, err + if err != nil { + return stats, err + } + + stats.AllCount = stats.OpenCount + stats.ClosedCount + + return stats, nil } func applyIssuesOptions(sess *xorm.Session, opts *IssuesOptions, issueIDs []int64) *xorm.Session { diff --git a/models/issues/issue_stats_test.go b/models/issues/issue_stats_test.go index fda75a6b47..9967557337 100644 --- a/models/issues/issue_stats_test.go +++ b/models/issues/issue_stats_test.go @@ -25,6 +25,7 @@ func TestGetIssueStats(t *testing.T) { assert.Equal(t, int64(4), stats.OpenCount) assert.Equal(t, int64(1), stats.ClosedCount) + assert.Equal(t, int64(5), stats.AllCount) assert.Equal(t, int64(0), stats.YourRepositoriesCount) assert.Equal(t, int64(0), stats.AssignCount) assert.Equal(t, int64(0), stats.CreateCount) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 708bd49142..2279efa279 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1608,6 +1608,7 @@ issues.previous = Previous issues.next = Next issues.open_title = Open issues.closed_title = Closed +issues.all_title = All issues.draft_title = Draft issues.num_comments_1 = %d comment issues.num_comments = %d comments diff --git a/release-notes/4125.md b/release-notes/4125.md new file mode 100644 index 0000000000..4e1e401285 --- /dev/null +++ b/release-notes/4125.md @@ -0,0 +1 @@ +Added link to show all Issues/PullRequests diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index 5d13ccc97c..2f077572ac 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -456,6 +456,7 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption opt ctx.Data["IssueStats"] = issueStats ctx.Data["OpenCount"] = issueStats.OpenCount ctx.Data["ClosedCount"] = issueStats.ClosedCount + ctx.Data["AllCount"] = issueStats.AllCount linkStr := "%s?q=%s&type=%s&sort=%s&state=%s&labels=%s&milestone=%d&project=%d&assignee=%d&poster=%d&archived=%t" ctx.Data["AllStatesLink"] = fmt.Sprintf(linkStr, ctx.Link, url.QueryEscape(keyword), url.QueryEscape(viewType), url.QueryEscape(sortType), "all", url.QueryEscape(selectLabels), diff --git a/templates/repo/issue/openclose.tmpl b/templates/repo/issue/openclose.tmpl index eb2d6e09ee..5de1d1f639 100644 --- a/templates/repo/issue/openclose.tmpl +++ b/templates/repo/issue/openclose.tmpl @@ -1,5 +1,5 @@ diff --git a/tests/integration/issue_test.go b/tests/integration/issue_test.go index 909242efc6..f6713519c6 100644 --- a/tests/integration/issue_test.go +++ b/tests/integration/issue_test.go @@ -1301,3 +1301,21 @@ func TestIssueUserDashboard(t *testing.T) { htmlDoc.AssertElement(t, sel, true) } } + +func TestIssueCount(t *testing.T) { + defer tests.PrepareTestEnv(t)() + + req := NewRequest(t, "GET", "/user2/repo1/issues") + resp := MakeRequest(t, req, http.StatusOK) + + htmlDoc := NewHTMLParser(t, resp.Body) + + openCount := htmlDoc.doc.Find("a[data-test-name='open-issue-count']").Text() + assert.Contains(t, openCount, "1\u00a0Open") + + closedCount := htmlDoc.doc.Find("a[data-test-name='closed-issue-count']").Text() + assert.Contains(t, closedCount, "1\u00a0Closed") + + allCount := htmlDoc.doc.Find("a[data-test-name='all-issue-count']").Text() + assert.Contains(t, allCount, "2\u00a0All") +}