diff --git a/templates/repo/contributors.tmpl b/templates/repo/contributors.tmpl index 6b8a63fe9964d..882d8b205cf2e 100644 --- a/templates/repo/contributors.tmpl +++ b/templates/repo/contributors.tmpl @@ -1,6 +1,7 @@ {{if .Permission.CanRead ctx.Consts.RepoUnitTypeCode}}
import {SvgIcon} from '../svg.ts'; +import dayjs from 'dayjs'; import { Chart, Title, @@ -26,6 +27,7 @@ import {sleep} from '../utils.ts'; import 'chartjs-adapter-dayjs-4/dist/chartjs-adapter-dayjs-4.esm'; import {fomanticQuery} from '../modules/fomantic/base.ts'; import type {Entries} from 'type-fest'; +import {pathEscapeSegments} from '../utils/url.ts'; const customEventListener: Plugin = { id: 'customEventListener', @@ -65,6 +67,10 @@ export default { type: String, required: true, }, + repoDefaultBranchName: { + type: String, + required: true, + }, }, data: () => ({ isLoading: false, @@ -100,6 +106,15 @@ export default { .slice(0, 100); }, + getContributorSearchQuery(contributorEmail: string) { + 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 { @@ -167,7 +182,7 @@ export default { // for details. user.max_contribution_type += 1; - filteredData[key] = {...user, weeks: filteredWeeks}; + filteredData[key] = {...user, weeks: filteredWeeks, email: key}; } return filteredData; @@ -215,7 +230,7 @@ export default { }; }, - updateOtherCharts({chart}: {chart: Chart}, reset?: boolean = false) { + updateOtherCharts({chart}: {chart: Chart}, reset: boolean = false) { const minVal = chart.options.scales.x.min; const maxVal = chart.options.scales.x.max; if (reset) { @@ -381,7 +396,7 @@ export default {
#{{ index + 1 }} - +

{{ contributor.name }}

@@ -389,7 +404,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.ts b/web_src/js/features/contributors.ts index 475c66e90060a..95fc81f5b368b 100644 --- a/web_src/js/features/contributors.ts +++ b/web_src/js/features/contributors.ts @@ -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: {