From 28362195a0ecbf1f68167d5d9dee13c691079afe Mon Sep 17 00:00:00 2001 From: jaqra <48099350+jaqra@users.noreply.github.com> Date: Wed, 18 Sep 2019 10:24:44 +0300 Subject: [PATCH] Add 'Mentioning you' group to /issues page (#8201) --- models/issue.go | 23 +++++++++++++++++++++++ routers/user/home.go | 2 ++ templates/user/dashboard/issues.tmpl | 4 ++++ 3 files changed, 29 insertions(+) diff --git a/models/issue.go b/models/issue.go index 511bfa31c..87e64ce99 100644 --- a/models/issue.go +++ b/models/issue.go @@ -1682,6 +1682,21 @@ func GetUserIssueStats(opts UserIssueStatsOptions) (*IssueStats, error) { if err != nil { return nil, err } + case FilterModeMention: + stats.OpenCount, err = x.Where(cond).And("is_closed = ?", false). + Join("INNER", "issue_user", "issue.id = issue_user.issue_id and issue_user.is_mentioned = ?", true). + And("issue_user.uid = ?", opts.UserID). + Count(new(Issue)) + if err != nil { + return nil, err + } + stats.ClosedCount, err = x.Where(cond).And("is_closed = ?", true). + Join("INNER", "issue_user", "issue.id = issue_user.issue_id and issue_user.is_mentioned = ?", true). + And("issue_user.uid = ?", opts.UserID). + Count(new(Issue)) + if err != nil { + return nil, err + } } cond = cond.And(builder.Eq{"issue.is_closed": opts.IsClosed}) @@ -1700,6 +1715,14 @@ func GetUserIssueStats(opts UserIssueStatsOptions) (*IssueStats, error) { return nil, err } + stats.MentionCount, err = x.Where(cond). + Join("INNER", "issue_user", "issue.id = issue_user.issue_id and issue_user.is_mentioned = ?", true). + And("issue_user.uid = ?", opts.UserID). + Count(new(Issue)) + if err != nil { + return nil, err + } + stats.YourRepositoriesCount, err = x.Where(cond). And(builder.In("issue.repo_id", opts.UserRepoIDs)). Count(new(Issue)) diff --git a/routers/user/home.go b/routers/user/home.go index 0c7dfec7f..40b3bc3fc 100644 --- a/routers/user/home.go +++ b/routers/user/home.go @@ -181,6 +181,8 @@ func Issues(ctx *context.Context) { filterMode = models.FilterModeAssign case "created_by": filterMode = models.FilterModeCreate + case "mentioned": + filterMode = models.FilterModeMention case "all": // filterMode already set to All default: viewType = "all" diff --git a/templates/user/dashboard/issues.tmpl b/templates/user/dashboard/issues.tmpl index 092eb9c7e..b1d0ee419 100644 --- a/templates/user/dashboard/issues.tmpl +++ b/templates/user/dashboard/issues.tmpl @@ -18,6 +18,10 @@ {{.i18n.Tr "repo.issues.filter_type.created_by_you"}} {{.IssueStats.CreateCount}} + + {{.i18n.Tr "repo.issues.filter_type.mentioning_you"}} + {{.IssueStats.MentionCount}} + {{end}}
{{range .Repos}}