Monorepo for Tangled tangled.org

appview/pages: show monthly commit count in profile timeline

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

oppi.li 2133cc81 f5a9a663

verified
Changed files
+22 -1
appview
models
pages
templates
state
+3 -1
appview/models/profile.go
··· 111 } 112 113 type ByMonth struct { 114 RepoEvents []RepoEvent 115 IssueEvents IssueEvents 116 PullEvents PullEvents ··· 119 func (b ByMonth) IsEmpty() bool { 120 return len(b.RepoEvents) == 0 && 121 len(b.IssueEvents.Items) == 0 && 122 - len(b.PullEvents.Items) == 0 123 } 124 125 type IssueEvents struct {
··· 111 } 112 113 type ByMonth struct { 114 + Commits int 115 RepoEvents []RepoEvent 116 IssueEvents IssueEvents 117 PullEvents PullEvents ··· 120 func (b ByMonth) IsEmpty() bool { 121 return len(b.RepoEvents) == 0 && 122 len(b.IssueEvents.Items) == 0 && 123 + len(b.PullEvents.Items) == 0 && 124 + b.Commits == 0 125 } 126 127 type IssueEvents struct {
+10
appview/pages/templates/user/overview.html
··· 33 </p> 34 35 <div class="flex flex-col gap-1"> 36 {{ block "repoEvents" .RepoEvents }} {{ end }} 37 {{ block "issueEvents" .IssueEvents }} {{ end }} 38 {{ block "pullEvents" .PullEvents }} {{ end }} ··· 43 {{ end }} 44 {{ end }} 45 </div> 46 {{ end }} 47 48 {{ define "repoEvents" }}
··· 33 </p> 34 35 <div class="flex flex-col gap-1"> 36 + {{ block "commits" .Commits }} {{ end }} 37 {{ block "repoEvents" .RepoEvents }} {{ end }} 38 {{ block "issueEvents" .IssueEvents }} {{ end }} 39 {{ block "pullEvents" .PullEvents }} {{ end }} ··· 44 {{ end }} 45 {{ end }} 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 }} 56 {{ end }} 57 58 {{ define "repoEvents" }}
+9
appview/state/profile.go
··· 161 l.Error("failed to create timeline", "err", err) 162 } 163 164 s.pages.ProfileOverview(w, pages.ProfileOverviewParams{ 165 LoggedInUser: s.oauth.GetUser(r), 166 Card: profile,
··· 161 l.Error("failed to create timeline", "err", err) 162 } 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 + 173 s.pages.ProfileOverview(w, pages.ProfileOverviewParams{ 174 LoggedInUser: s.oauth.GetUser(r), 175 Card: profile,