diff --git a/templates/repo/contributors.tmpl b/templates/repo/contributors.tmpl index f7f5d796f4..c71312fc6c 100644 --- a/templates/repo/contributors.tmpl +++ b/templates/repo/contributors.tmpl @@ -1,6 +1,7 @@ {{if .Permission.CanRead $.UnitTypeCode}}
import {SvgIcon} from '../svg.js'; +import dayjs from 'dayjs'; import { Chart, Title, @@ -22,6 +23,7 @@ import {chartJsColors} from '../utils/color.js'; import {sleep} from '../utils.js'; import 'chartjs-adapter-dayjs-4/dist/chartjs-adapter-dayjs-4.esm'; import $ from 'jquery'; +import {pathEscapeSegments} from '../utils/url.js'; const customEventListener = { id: 'customEventListener', @@ -61,6 +63,10 @@ export default { type: String, required: true, }, + repoDefaultBranchName: { + type: String, + required: true, + }, }, data: () => ({ isLoading: false, @@ -96,6 +102,15 @@ export default { .slice(0, 100); }, + getContributorSearchQuery(contributorEmail) { + const min = dayjs(this.xAxisMin).format('YYYY-MM-DD'); + const max = dayjs(this.xAxisMax).format('YYYY-MM-DD'); + const params = new URLSearchParams({ + 'q': `after:${min}, before:${max}, author:${contributorEmail}`, + }); + return `${this.repoLink}/commits/branch/${pathEscapeSegments(this.repoDefaultBranchName)}/search?${params.toString()}`; + }, + async fetchGraphData() { this.isLoading = true; try { @@ -163,7 +178,7 @@ export default { // for details. user.max_contribution_type += 1; - filteredData[key] = {...user, weeks: filteredWeeks}; + filteredData[key] = {...user, weeks: filteredWeeks, email: key}; } return filteredData; @@ -376,7 +391,7 @@ export default {
#{{ index + 1 }} - +

{{ contributor.name }}

@@ -384,7 +399,11 @@ 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() }}-- diff --git a/web_src/js/features/contributors.js b/web_src/js/features/contributors.js index 79b3389fee..c0106b6350 100644 --- a/web_src/js/features/contributors.js +++ b/web_src/js/features/contributors.js @@ -8,6 +8,7 @@ export async function initRepoContributors() { try { const View = createApp(RepoContributors, { repoLink: el.getAttribute('data-repo-link'), + repoDefaultBranchName: el.getAttribute('data-repo-default-branch-name'), locale: { filterLabel: el.getAttribute('data-locale-filter-label'), contributionType: {