Mirror of @tangled.org/core. Running on a Raspberry Pi Zero 2 (Please be gentle).
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

appview/pages: show monthly commit count in profile timeline

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

authored by

oppiliappan and committed by
Tangled
4b0a917e 7dea751c

+22 -1
+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 ··· 120 119 func (b ByMonth) IsEmpty() bool { 121 120 return len(b.RepoEvents) == 0 && 122 121 len(b.IssueEvents.Items) == 0 && 123 - len(b.PullEvents.Items) == 0 122 + len(b.PullEvents.Items) == 0 && 123 + b.Commits == 0 124 124 } 125 125 126 126 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 }} ··· 44 43 {{ end }} 45 44 {{ end }} 46 45 </div> 46 + {{ end }} 47 + 48 + {{ define "commits" }} 49 + {{ if . }} 50 + <div class="flex flex-wrap items-center gap-1"> 51 + {{ i "git-commit-horizontal" "size-5" }} 52 + created {{ . }} commits 53 + </div> 54 + {{ end }} 47 55 {{ end }} 48 56 49 57 {{ 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,