From 2eefed9b1a41532eccee234b88c7bb13af506aa7 Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Tue, 24 Aug 2021 19:33:04 +0100 Subject: [PATCH 1/2] Report the correct number of pushes on the feeds Since the number of commits in the Action table has been limited to 5 the number of commits reported on the feeds page is now incorrectly also limited to 5. The correct number is available as the Len and this PR changes this to report this. Fix #16804 Signed-off-by: Andrew Thornton --- modules/repository/commits.go | 10 +++++++++- modules/templates/helper.go | 5 +++++ templates/user/dashboard/feeds.tmpl | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/modules/repository/commits.go b/modules/repository/commits.go index 7f22105745ee..1558d8563905 100644 --- a/modules/repository/commits.go +++ b/modules/repository/commits.go @@ -30,6 +30,7 @@ type PushCommits struct { Commits []*PushCommit HeadCommit *PushCommit CompareURL string + Len int avatars map[string]string emailUsers map[string]*models.User @@ -180,5 +181,12 @@ func GitToPushCommits(gitCommits []*git.Commit) *PushCommits { for _, commit := range gitCommits { commits = append(commits, CommitToPushCommit(commit)) } - return &PushCommits{commits, nil, "", make(map[string]string), make(map[string]*models.User)} + return &PushCommits{ + Commits: commits, + HeadCommit: nil, + CompareURL: "", + Len: len(commits), + avatars: make(map[string]string), + emailUsers: make(map[string]*models.User), + } } diff --git a/modules/templates/helper.go b/modules/templates/helper.go index 6517127ebf45..00b07dcec948 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -819,6 +819,11 @@ func ActionContent2Commits(act Actioner) *repository.PushCommits { if err := json.Unmarshal([]byte(act.GetContent()), push); err != nil { log.Error("json.Unmarshal:\n%s\nERROR: %v", act.GetContent(), err) } + + if push.Len == 0 { + push.Len = len(push.Commits) + } + return push } diff --git a/templates/user/dashboard/feeds.tmpl b/templates/user/dashboard/feeds.tmpl index 1b770d4472a3..8ac55718c9db 100644 --- a/templates/user/dashboard/feeds.tmpl +++ b/templates/user/dashboard/feeds.tmpl @@ -99,7 +99,7 @@ {{end}} - {{if and (gt (len $push.Commits) 1) $push.CompareURL}}
  • {{$.i18n.Tr "action.compare_commits" (len $push.Commits)}} »
  • {{end}} + {{if and (gt (len $push.Commits) 1) $push.CompareURL}}
  • {{$.i18n.Tr "action.compare_commits" $push.Len}} »
  • {{end}} {{else if eq .GetOpType 6}} From f36ad4563cf909c9c9140033d08f7e552c86cc33 Mon Sep 17 00:00:00 2001 From: zeripath Date: Tue, 24 Aug 2021 23:17:42 +0100 Subject: [PATCH 2/2] Update templates/user/dashboard/feeds.tmpl --- templates/user/dashboard/feeds.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/user/dashboard/feeds.tmpl b/templates/user/dashboard/feeds.tmpl index 8ac55718c9db..83d064dc9529 100644 --- a/templates/user/dashboard/feeds.tmpl +++ b/templates/user/dashboard/feeds.tmpl @@ -99,7 +99,7 @@ {{end}} - {{if and (gt (len $push.Commits) 1) $push.CompareURL}}
  • {{$.i18n.Tr "action.compare_commits" $push.Len}} »
  • {{end}} + {{if and (gt $push.Len 1) $push.CompareURL}}
  • {{$.i18n.Tr "action.compare_commits" $push.Len}} »
  • {{end}} {{else if eq .GetOpType 6}}