-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Add "n commits" link to contributors in contributors graph page #29429
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: silverwind <me@silverwind.io>
@@ -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 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.
Actually this.repoBranch might need to use path segment escape.
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 /
to encodeURIComponent
if it's part of the path, it's meant for individual path segments or search param values.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
this.searchQuery = `${this.repoLink}/commits/branch/${this.repoBranch}/search?q=after:${min}, before:${max}, author:`; | |
this.searchQuery = `${this.repoLink}/commits/branch/${this.repoBranch}/search?q=after:${min},before:${max},author:`; |
also, it looks really weird to construct the search query like this.
Wouldn't it make more sense to have ?after=…&before=…&author=…
?
And is all that functionality already supported?
I would have guessed that you need to add it yourself…
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.
Ideally we should use URLSearchParams
to construct search params:
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it make more sense to have ?after=…&before=…&author=…?
yeah, it would. But I can't do that way because it is not something I decided. Gitea currently works the other way.
And is all that functionality already supported?
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 comment
The 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.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
What about users having multiple emails?
For those, only the primary email will be counted if I see that correctly…
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.
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 u != nil { | |
// update userEmail with user's primary email address so | |
// that different mail addresses will linked to same account | |
userEmail = u.GetEmail() | |
} |
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)
Yeah, it's a good change @yp05327. Feel free to open a PR in my fork and I will accept it. |
This is how GH has it and I think I'm fine with it. Could also mute both links or even use
#29283 will make links blue soon on dark theme. |
Sorry, I'm afraid I can't finish this, as I'm not good at CSS, so the screenshot is made by PPT. 😭
Then the user name and the |
Yes, in fact I made that exact class in another open PR, we can copy the CSS: |
#29847 will add this support for |
Extract from go-gitea/gitea#29344. With this class it's possible to have links that don't color on hover. It will be useful for go-gitea/gitea#29429. (cherry picked from commit ffeaf2d0bd6c99c486aa7869779bb9ceb0aedad6)
Stale for long time? |
Fixes #29365.