Skip to content

Commit

Permalink
Report the correct number of pushes on the feeds (#16811)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

* Update templates/user/dashboard/feeds.tmpl

Co-authored-by: techknowlogick <[email protected]>
  • Loading branch information
zeripath and techknowlogick authored Aug 25, 2021
1 parent 28ac4a7 commit ba6baff
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
10 changes: 9 additions & 1 deletion modules/repository/commits.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type PushCommits struct {
Commits []*PushCommit
HeadCommit *PushCommit
CompareURL string
Len int

avatars map[string]string
emailUsers map[string]*models.User
Expand Down Expand Up @@ -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),
}
}
5 changes: 5 additions & 0 deletions modules/templates/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion templates/user/dashboard/feeds.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
</span>
</li>
{{end}}
{{if and (gt (len $push.Commits) 1) $push.CompareURL}}<li><a href="{{AppSubUrl}}/{{$push.CompareURL}}">{{$.i18n.Tr "action.compare_commits" (len $push.Commits)}} »</a></li>{{end}}
{{if and (gt $push.Len 1) $push.CompareURL}}<li><a href="{{AppSubUrl}}/{{$push.CompareURL}}">{{$.i18n.Tr "action.compare_commits" $push.Len}} »</a></li>{{end}}
</ul>
</div>
{{else if eq .GetOpType 6}}
Expand Down

0 comments on commit ba6baff

Please sign in to comment.