From 071184cae517cb4d2f389bf230f20af7975ac4de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=9Eahin=20Akkaya?= Date: Mon, 26 Feb 2024 19:27:30 +0300 Subject: [PATCH 1/5] Add "n commits" link to contributors in contributors graph page --- routers/web/repo/contributors.go | 1 + web_src/js/components/RepoContributors.vue | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/routers/web/repo/contributors.go b/routers/web/repo/contributors.go index bcfef7580a6a3..62973d6123adc 100644 --- a/routers/web/repo/contributors.go +++ b/routers/web/repo/contributors.go @@ -26,6 +26,7 @@ func Contributors(ctx *context.Context) { ctx.PageData["contributionType"] = "commits" ctx.PageData["repoLink"] = ctx.Repo.RepoLink + ctx.PageData["repoDefaultBranch"] = ctx.Repo.RefName ctx.HTML(http.StatusOK, tplContributors) } diff --git a/web_src/js/components/RepoContributors.vue b/web_src/js/components/RepoContributors.vue index 84fdcae1f61da..4fa2a9391eee4 100644 --- a/web_src/js/components/RepoContributors.vue +++ b/web_src/js/components/RepoContributors.vue @@ -66,12 +66,14 @@ export default { totalStats: {}, sortedContributors: {}, repoLink: pageData.repoLink || [], + repoBranch: pageData.repoDefaultBranch || [], type: pageData.contributionType, contributorsStats: [], xAxisStart: null, xAxisEnd: null, xAxisMin: null, xAxisMax: null, + searchQuery: '', }), mounted() { this.fetchGraphData(); @@ -88,6 +90,9 @@ export default { methods: { sortContributors() { const contributors = this.filterContributorWeeksByDateRange(); + const min = new Date(this.xAxisMin).toISOString().split('T')[0]; + const max = new Date(this.xAxisMax).toISOString().split('T')[0]; + this.searchQuery = `${this.repoLink}/commits/branch/${this.repoBranch}/search?q=after:${min}, before:${max}, author:`; const criteria = `total_${this.type}`; this.sortedContributors = Object.values(contributors) .filter((contributor) => contributor[criteria] !== 0) @@ -162,7 +167,7 @@ export default { // for details. user.max_contribution_type += 1; - filteredData[key] = {...user, weeks: filteredWeeks}; + filteredData[key] = {...user, weeks: filteredWeeks, email: key}; } return filteredData; @@ -384,7 +389,7 @@ export default { {{ contributor.name }}

- {{ contributor.total_commits.toLocaleString() }} {{ locale.contributionType.commits }} + {{ contributor.total_commits.toLocaleString() }} {{ locale.contributionType.commits }} {{ contributor.total_additions.toLocaleString() }}++ {{ contributor.total_deletions.toLocaleString() }}-- From dc8533f9823700983048a8f84bf97ffcf10cf8cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=9Eahin=20Akkaya?= Date: Mon, 26 Feb 2024 19:33:28 +0300 Subject: [PATCH 2/5] Make link text strong --- web_src/js/components/RepoContributors.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_src/js/components/RepoContributors.vue b/web_src/js/components/RepoContributors.vue index 4fa2a9391eee4..67e06ce83584e 100644 --- a/web_src/js/components/RepoContributors.vue +++ b/web_src/js/components/RepoContributors.vue @@ -389,7 +389,7 @@ export default { {{ contributor.name }}

- {{ contributor.total_commits.toLocaleString() }} {{ locale.contributionType.commits }} + {{ contributor.total_commits.toLocaleString() }} {{ locale.contributionType.commits }} {{ contributor.total_additions.toLocaleString() }}++ {{ contributor.total_deletions.toLocaleString() }}-- From f20cd380b2e584d150b79b8fcf54a08ccfc202d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=9Eahin=20Akkaya?= Date: Mon, 26 Feb 2024 19:40:56 +0300 Subject: [PATCH 3/5] Apply suggestions from code review --- routers/web/repo/contributors.go | 9 +++++---- web_src/js/components/RepoContributors.vue | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/routers/web/repo/contributors.go b/routers/web/repo/contributors.go index 62973d6123adc..b432ba0b6c198 100644 --- a/routers/web/repo/contributors.go +++ b/routers/web/repo/contributors.go @@ -23,10 +23,11 @@ func Contributors(ctx *context.Context) { ctx.Data["PageIsActivity"] = true ctx.Data["PageIsContributors"] = true - ctx.PageData["contributionType"] = "commits" - - ctx.PageData["repoLink"] = ctx.Repo.RepoLink - ctx.PageData["repoDefaultBranch"] = ctx.Repo.RefName + ctx.PageData["repoContributorsData"] = map[string]any{ + "contributionType": "commits", + "repoLink": ctx.Repo.RepoLink, + "repoDefaultBranch": ctx.Repo.RefName, + } ctx.HTML(http.StatusOK, tplContributors) } diff --git a/web_src/js/components/RepoContributors.vue b/web_src/js/components/RepoContributors.vue index 67e06ce83584e..fd6845627664c 100644 --- a/web_src/js/components/RepoContributors.vue +++ b/web_src/js/components/RepoContributors.vue @@ -65,9 +65,9 @@ export default { errorText: '', totalStats: {}, sortedContributors: {}, - repoLink: pageData.repoLink || [], - repoBranch: pageData.repoDefaultBranch || [], - type: pageData.contributionType, + repoLink: pageData.repoContributorsData.repoLink || [], + repoBranch: pageData.repoContributorsData.repoDefaultBranch || [], + type: pageData.repoContributorsData.contributionType, contributorsStats: [], xAxisStart: null, xAxisEnd: null, From abdb2750a68a23337091e5e6eb4968c1073b66cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=9Eahin=20Akkaya?= Date: Mon, 26 Feb 2024 19:54:40 +0300 Subject: [PATCH 4/5] Update web_src/js/components/RepoContributors.vue Co-authored-by: silverwind --- web_src/js/components/RepoContributors.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web_src/js/components/RepoContributors.vue b/web_src/js/components/RepoContributors.vue index fd6845627664c..ad763d40b77c8 100644 --- a/web_src/js/components/RepoContributors.vue +++ b/web_src/js/components/RepoContributors.vue @@ -90,8 +90,8 @@ export default { methods: { sortContributors() { const contributors = this.filterContributorWeeksByDateRange(); - const min = new Date(this.xAxisMin).toISOString().split('T')[0]; - const max = new Date(this.xAxisMax).toISOString().split('T')[0]; + const min = dayjs(this.xAxisMin).format('YYYY-MM-DD'); + const max = dayjs(this.xAxisMax).format('YYYY-MM-DD'); this.searchQuery = `${this.repoLink}/commits/branch/${this.repoBranch}/search?q=after:${min}, before:${max}, author:`; const criteria = `total_${this.type}`; this.sortedContributors = Object.values(contributors) From d26364f19f850ae5c5d9ef456cbc199e358ce467 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=9Eahin=20Akkaya?= Date: Mon, 26 Feb 2024 19:56:58 +0300 Subject: [PATCH 5/5] Import dayjs --- web_src/js/components/RepoContributors.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/web_src/js/components/RepoContributors.vue b/web_src/js/components/RepoContributors.vue index ad763d40b77c8..79c3fc91eb729 100644 --- a/web_src/js/components/RepoContributors.vue +++ b/web_src/js/components/RepoContributors.vue @@ -1,5 +1,6 @@