-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Add "n commits" link to contributors in contributors graph page #29429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
071184c
dc8533f
f20cd38
abdb275
d26364f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,5 +1,6 @@ | ||||||||||||
<script> | ||||||||||||
import {SvgIcon} from '../svg.js'; | ||||||||||||
import dayjs from 'dayjs'; | ||||||||||||
import { | ||||||||||||
Chart, | ||||||||||||
Title, | ||||||||||||
|
@@ -65,13 +66,15 @@ export default { | |||||||||||
errorText: '', | ||||||||||||
totalStats: {}, | ||||||||||||
sortedContributors: {}, | ||||||||||||
repoLink: pageData.repoLink || [], | ||||||||||||
type: pageData.contributionType, | ||||||||||||
repoLink: pageData.repoContributorsData.repoLink || [], | ||||||||||||
repoBranch: pageData.repoContributorsData.repoDefaultBranch || [], | ||||||||||||
type: pageData.repoContributorsData.contributionType, | ||||||||||||
contributorsStats: [], | ||||||||||||
xAxisStart: null, | ||||||||||||
xAxisEnd: null, | ||||||||||||
xAxisMin: null, | ||||||||||||
xAxisMax: null, | ||||||||||||
searchQuery: '', | ||||||||||||
}), | ||||||||||||
mounted() { | ||||||||||||
this.fetchGraphData(); | ||||||||||||
|
@@ -88,6 +91,9 @@ export default { | |||||||||||
methods: { | ||||||||||||
sortContributors() { | ||||||||||||
const contributors = this.filterContributorWeeksByDateRange(); | ||||||||||||
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:`; | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
also, it looks really weird to construct the search query like this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally we should use String(new URLSearchParams({foo: "bar", baz: "a b"}))
// 'foo=bar&baz=a+b' There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
yeah, it would. But I can't do that way because it is not something I decided. Gitea currently works the other way.
Yes. And it won't work if I accept your code suggestion. The spaces are important. As I said, this is how it works. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it's existing API, I guess this weird format is okay, otherwise it would be a breaking change. Still we should ensure the individual paramters and path segments are encoded correctly. |
||||||||||||
const criteria = `total_${this.type}`; | ||||||||||||
this.sortedContributors = Object.values(contributors) | ||||||||||||
.filter((contributor) => contributor[criteria] !== 0) | ||||||||||||
|
@@ -162,7 +168,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 +390,7 @@ export default { | |||||||||||
{{ contributor.name }} | ||||||||||||
</h4> | ||||||||||||
<p class="gt-font-12 gt-df gt-gap-2"> | ||||||||||||
<strong v-if="contributor.total_commits">{{ contributor.total_commits.toLocaleString() }} {{ locale.contributionType.commits }}</strong> | ||||||||||||
<strong v-if="contributor.total_commits"><a :href="searchQuery + contributor.email">{{ contributor.total_commits.toLocaleString() }} {{ locale.contributionType.commits }}</a></strong> | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about users having multiple emails? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All email addresses of a user are mapped to their primary email address in backend. See: gitea/services/repository/contributors_graph.go Lines 250 to 254 in 324626a
If I don't do that, we will see same user multiple times in the contributor graphs page (for multiple emails). And problem you mentioned will be fixed. But I would prefer it this way as it looks cleaner. I guess it doesn't have to be perfect all the times. If you really want it to be perfect, you may modify the backend code to include commits of a user with their other email addresses when queried (maybe it already works this way, I didn't check) |
||||||||||||
<strong v-if="contributor.total_additions" class="text green">{{ contributor.total_additions.toLocaleString() }}++ </strong> | ||||||||||||
<strong v-if="contributor.total_deletions" class="text red"> | ||||||||||||
{{ contributor.total_deletions.toLocaleString() }}--</strong> | ||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to
encodeURIComponent(this.repoBranch)
? Try with a branch name that contains a space character.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup.
Actually
this.repoBranch
might need to use path segment escape.The
q
parameter also needs to be escaped (encodeURIComponent)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no path escape function in JS, I think
encodeURIComponent
is suitable for alle cases, path or search params.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess "org/repo/branch/feature%2Fbranch" doesn't work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you can not pass
/
toencodeURIComponent
if it's part of the path, it's meant for individual path segments or search param values.