forked from tangled.org/core
Monorepo for Tangled

appview/pages: show monthly commit count in profile timeline

Signed-off-by: oppiliappan <me@oppi.li>

authored by oppi.li and committed by Tangled 4b0a917e 7dea751c

Changed files
+22 -1
appview
models
pages
templates
state
+3 -1
appview/models/profile.go
··· 111 111 } 112 112 113 113 type ByMonth struct { 114 + Commits int 114 115 RepoEvents []RepoEvent 115 116 IssueEvents IssueEvents 116 117 PullEvents PullEvents ··· 119 120 func (b ByMonth) IsEmpty() bool { 120 121 return len(b.RepoEvents) == 0 && 121 122 len(b.IssueEvents.Items) == 0 && 122 - len(b.PullEvents.Items) == 0 123 + len(b.PullEvents.Items) == 0 && 124 + b.Commits == 0 123 125 } 124 126 125 127 type IssueEvents struct {
+10
appview/pages/templates/user/overview.html
··· 33 33 </p> 34 34 35 35 <div class="flex flex-col gap-1"> 36 + {{ block "commits" .Commits }} {{ end }} 36 37 {{ block "repoEvents" .RepoEvents }} {{ end }} 37 38 {{ block "issueEvents" .IssueEvents }} {{ end }} 38 39 {{ block "pullEvents" .PullEvents }} {{ end }} ··· 43 44 {{ end }} 44 45 {{ end }} 45 46 </div> 47 + {{ end }} 48 + 49 + {{ define "commits" }} 50 + {{ if . }} 51 + <div class="flex flex-wrap items-center gap-1"> 52 + {{ i "git-commit-horizontal" "size-5" }} 53 + created {{ . }} commits 54 + </div> 55 + {{ end }} 46 56 {{ end }} 47 57 48 58 {{ define "repoEvents" }}
+9
appview/state/profile.go
··· 161 161 l.Error("failed to create timeline", "err", err) 162 162 } 163 163 164 + // populate commit counts in the timeline, using the punchcard 165 + currentMonth := time.Now().Month() 166 + for _, p := range profile.Punchcard.Punches { 167 + idx := currentMonth - p.Date.Month() 168 + if int(idx) < len(timeline.ByMonth) { 169 + timeline.ByMonth[idx].Commits += p.Count 170 + } 171 + } 172 + 164 173 s.pages.ProfileOverview(w, pages.ProfileOverviewParams{ 165 174 LoggedInUser: s.oauth.GetUser(r), 166 175 Card: profile,