-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Drop column NumFollowers and NumFollowing #24676
Conversation
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 I haven't quite understood:
You only remove in this PR.
Where do you calculate it?
I don't think it's a good idea to extract the calculation into another PR.
The profile page calculates this value always, so nothing is missing. But the API needs that calculation too. |
It is calculated by And not only |
Document the deprecation in the PR description |
Updated. |
After finish #24676 (comment), I will convert this PR into Open state. |
980aab9
to
8645c5c
Compare
// 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 { | ||
// accessMode is only used if doer is nil | ||
func toUser(ctx context.Context, user, doer *user_model.User, accessMode perm.AccessMode) *api.User { |
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.
Looks like accessMode
is always perm.AccessModeNone
, maybe we should remove it.
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 doer
is nil, we use accessMode
to check whether provide Email
info.
} | ||
result.Following = int(count) | ||
} else if accessMode != perm.AccessModeNone { | ||
signed = true |
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.
An non-login user has read premission to a public repository.
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 is the problem? The logic is same to the old code.
authed = doer.ID == user.ID || doer.IsAdmin | ||
} | ||
return toUser(ctx, user, signed, authed) | ||
return toUser(ctx, user, doer, perm.AccessModeNone) |
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.
Looks like it's unrelated changes?
In old design, we had no user visibility, so we stored them as const variables in db.
Since we added user visibility, we should check whether user can see someone, so there was a fix in #20220.
But we didn't notice these unnecessary const variables in db, as they are dynamically calculated by
user_model.GetUserFollowers
anduser_model.GetUserFollowing
.Discussed in:
#24345 (comment)
#24345 (comment)