Skip to content
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

Fix wrong user star count #26544

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Conversation

JakobDev
Copy link
Contributor

@JakobDev JakobDev commented Aug 16, 2023

Fixes #26530
Fixes #27385

At the moment, the count of the stared repos is the total count. This also includes private repos, that the visitor of the profile is not able to see, which can result in confusion.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Aug 16, 2023
@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 16, 2023
@wolfogre
Copy link
Member

Wrong "fixes"?

@JakobDev
Copy link
Contributor Author

Wrong "fixes"?

Now fixed. It's now reference the correct Issue.

@@ -37,16 +39,23 @@ func ToUsers(ctx context.Context, doer *user_model.User, users []*user_model.Use

// ToUserWithAccessMode convert user_model.User to api.User
// AccessMode is not none show add some more information
func ToUserWithAccessMode(ctx context.Context, user *user_model.User, accessMode perm.AccessMode) *api.User {
func ToUserWithAccessMode(ctx context.Context, user, owner *user_model.User, accessMode perm.AccessMode) *api.User {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func ToUserWithAccessMode(ctx context.Context, user, owner *user_model.User, accessMode perm.AccessMode) *api.User {
func ToUserWithAccessMode(ctx context.Context, user, doer *user_model.User, accessMode perm.AccessMode) *api.User {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think they are not always the same

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lunny any more feedback?

Copy link
Member

@lunny lunny Apr 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean about the variables name. I think the second user should be the doer and the first one is the owner? I don't know the different between user and owner from the name themselves.

@silverwind silverwind added the backport/v1.21 This PR should be backported to Gitea 1.21 label Oct 2, 2023
@silverwind
Copy link
Member

Needs a merge

@github-actions github-actions bot added the modifies/api This PR adds API routes or modifies them label Oct 2, 2023
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Oct 2, 2023
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Oct 23, 2023
@puni9869
Copy link
Member

are we holding this pr as of now?

@silverwind
Copy link
Member

silverwind commented Oct 23, 2023

Waiting on @lunny to review, also one merge conflict.

@JakobDev
Copy link
Contributor Author

also one merge conflict.

should be fixed now

@puni9869
Copy link
Member

Any update on this one.

@yp05327
Copy link
Contributor

yp05327 commented Feb 16, 2024

backport/v1.21 added but not in v1.22's milestone?

Comment on lines 49 to +51
// toUser convert user_model.User to api.User
// signed shall only be set if requester is logged in. authed shall only be set if user is site admin or user himself
func toUser(ctx context.Context, user *user_model.User, signed, authed bool) *api.User {
func toUser(ctx context.Context, user, doer *user_model.User, signed, authed bool) *api.User {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, I have tried to fix #26530, but I met some problems of dealing with signed and authed here.
Normally, we can easily know whether doer is signed and authed, so it seems that signed and authed are unnecessary. But some callers don't have doer as param but permission access mode.
I didn't deeply check these callers why they have permission access mode but not doer. But it seems that it is a bit strange to me of simply add doer here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to know the current User. I see no other way to solve this problem.

@silverwind
Copy link
Member

silverwind commented Feb 23, 2024

Looks like we forgot about this one, but I'd be happy to merge it once the conflicts are resolved.

@silverwind
Copy link
Member

Another conflict and some lint errors..

@github-actions github-actions bot added modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files labels Apr 3, 2024
Actor: ctx.Doer,
Private: ctx.IsSigned,
StarredByID: ctx.ContextUser.ID,
Collaborate: util.OptionalBoolFalse,
Copy link
Member

@silverwind silverwind Apr 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Collaborate: util.OptionalBoolFalse,
Collaborate: optional.Some(false),

As per #29329. And import code.gitea.io/gitea/modules/optional above.

Actor: doer,
Private: signed,
StarredByID: user.ID,
Collaborate: util.OptionalBoolFalse,
Copy link
Member

@silverwind silverwind Apr 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Collaborate: util.OptionalBoolFalse,
Collaborate: optional.Some(false),

As per #29329. And import code.gitea.io/gitea/modules/optional above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/v1.21 This PR should be backported to Gitea 1.21 lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Starred Repository count is negative on try.git.io NumStars should also be removed
7 participants