Skip to content

Commit 60d0ed5

Browse files
author
Ben Chang
committed
Add "n commits" link to contributors in contributors graph page
1 parent 8a53a39 commit 60d0ed5

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

routers/web/repo/contributors.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ func Contributors(ctx *context.Context) {
2121
ctx.Data["Title"] = ctx.Tr("repo.activity.navbar.contributors")
2222
ctx.Data["PageIsActivity"] = true
2323
ctx.Data["PageIsContributors"] = true
24+
ctx.PageData["repoContributorsData"] = map[string]any{
25+
"repoDefaultBranch": ctx.Repo.RefName,
26+
}
2427
ctx.HTML(http.StatusOK, tplContributors)
2528
}
2629

web_src/js/components/RepoContributors.vue

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script lang="ts">
22
import {SvgIcon} from '../svg.ts';
3+
import dayjs from 'dayjs';
34
import {
45
Chart,
56
Title,
@@ -27,6 +28,8 @@ import 'chartjs-adapter-dayjs-4/dist/chartjs-adapter-dayjs-4.esm';
2728
import {fomanticQuery} from '../modules/fomantic/base.ts';
2829
import type {Entries} from 'type-fest';
2930
31+
const {pageData} = window.config;
32+
3033
const customEventListener: Plugin = {
3134
id: 'customEventListener',
3235
afterEvent: (chart, args, opts) => {
@@ -72,11 +75,13 @@ export default {
7275
totalStats: {} as Record<string, any>,
7376
sortedContributors: {} as Record<string, any>,
7477
type: 'commits',
78+
repoBranch: pageData.repoContributorsData.repoDefaultBranch,
7579
contributorsStats: {} as Record<string, any>,
7680
xAxisStart: null,
7781
xAxisEnd: null,
7882
xAxisMin: null,
7983
xAxisMax: null,
84+
searchQuery: '',
8085
}),
8186
mounted() {
8287
this.fetchGraphData();
@@ -93,6 +98,9 @@ export default {
9398
methods: {
9499
sortContributors() {
95100
const contributors = this.filterContributorWeeksByDateRange();
101+
const min = dayjs(this.xAxisMin).format('YYYY-MM-DD');
102+
const max = dayjs(this.xAxisMax).format('YYYY-MM-DD');
103+
this.searchQuery = `${this.repoLink}/commits/branch/${this.repoBranch}/search?q=after:${min}, before:${max}, author:`;
96104
const criteria = `total_${this.type}`;
97105
this.sortedContributors = Object.values(contributors)
98106
.filter((contributor) => contributor[criteria] !== 0)
@@ -167,7 +175,7 @@ export default {
167175
// for details.
168176
user.max_contribution_type += 1;
169177
170-
filteredData[key] = {...user, weeks: filteredWeeks};
178+
filteredData[key] = {...user, weeks: filteredWeeks, email: key};
171179
}
172180
173181
return filteredData;
@@ -389,7 +397,11 @@ export default {
389397
{{ contributor.name }}
390398
</h4>
391399
<p class="tw-text-12 tw-flex tw-gap-1">
392-
<strong v-if="contributor.total_commits">{{ contributor.total_commits.toLocaleString() }} {{ locale.contributionType.commits }}</strong>
400+
<strong v-if="contributor.total_commits">
401+
<a class="silenced" :href="searchQuery + contributor.email">
402+
{{ contributor.total_commits.toLocaleString() }} {{ locale.contributionType.commits }}
403+
</a>
404+
</strong>
393405
<strong v-if="contributor.total_additions" class="text green">{{ contributor.total_additions.toLocaleString() }}++ </strong>
394406
<strong v-if="contributor.total_deletions" class="text red">
395407
{{ contributor.total_deletions.toLocaleString() }}--</strong>

0 commit comments

Comments
 (0)