From 2133cc81f122bb28a6633b776d4d9a933912beb6 Mon Sep 17 00:00:00 2001
From: oppiliappan
Date: Fri, 5 Dec 2025 18:46:49 +0000
Subject: [PATCH] appview/pages: show monthly commit count in profile timeline
Change-Id: smtsyvpnzwlwxqoznokolwynslqxwsvl
Signed-off-by: oppiliappan
---
appview/models/profile.go | 4 +++-
appview/pages/templates/user/overview.html | 10 ++++++++++
appview/state/profile.go | 9 +++++++++
3 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/appview/models/profile.go b/appview/models/profile.go
index 70fb646b..193ce448 100644
--- a/appview/models/profile.go
+++ b/appview/models/profile.go
@@ -111,6 +111,7 @@ func (p *ProfileTimeline) IsEmpty() bool {
}
type ByMonth struct {
+ Commits int
RepoEvents []RepoEvent
IssueEvents IssueEvents
PullEvents PullEvents
@@ -119,7 +120,8 @@ type ByMonth struct {
func (b ByMonth) IsEmpty() bool {
return len(b.RepoEvents) == 0 &&
len(b.IssueEvents.Items) == 0 &&
- len(b.PullEvents.Items) == 0
+ len(b.PullEvents.Items) == 0 &&
+ b.Commits == 0
}
type IssueEvents struct {
diff --git a/appview/pages/templates/user/overview.html b/appview/pages/templates/user/overview.html
index 73ed6380..f7f73975 100644
--- a/appview/pages/templates/user/overview.html
+++ b/appview/pages/templates/user/overview.html
@@ -33,6 +33,7 @@
+ {{ block "commits" .Commits }} {{ end }}
{{ block "repoEvents" .RepoEvents }} {{ end }}
{{ block "issueEvents" .IssueEvents }} {{ end }}
{{ block "pullEvents" .PullEvents }} {{ end }}
@@ -45,6 +46,15 @@
{{ end }}
+{{ define "commits" }}
+ {{ if . }}
+
+ {{ i "git-commit-horizontal" "size-5" }}
+ created {{ . }} commits
+
+ {{ end }}
+{{ end }}
+
{{ define "repoEvents" }}
{{ if gt (len .) 0 }}
diff --git a/appview/state/profile.go b/appview/state/profile.go
index 759cbdac..7b8353a0 100644
--- a/appview/state/profile.go
+++ b/appview/state/profile.go
@@ -161,6 +161,15 @@ func (s *State) profileOverview(w http.ResponseWriter, r *http.Request) {
l.Error("failed to create timeline", "err", err)
}
+ // populate commit counts in the timeline, using the punchcard
+ currentMonth := time.Now().Month()
+ for _, p := range profile.Punchcard.Punches {
+ idx := currentMonth - p.Date.Month()
+ if int(idx) < len(timeline.ByMonth) {
+ timeline.ByMonth[idx].Commits += p.Count
+ }
+ }
+
s.pages.ProfileOverview(w, pages.ProfileOverviewParams{
LoggedInUser: s.oauth.GetUser(r),
Card: profile,
--
2.43.0