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

Small optimization for getTeamIDs #919

Merged
merged 2 commits into from
Feb 14, 2017

Conversation

lunny
Copy link
Member

@lunny lunny commented Feb 13, 2017

The latest XORM has supported only Find IDs. So let's use the new method.

@lunny lunny added the type/refactoring Existing code has been cleaned up. There should be no new functionality. label Feb 13, 2017
@lunny lunny added this to the 1.1.0 milestone Feb 13, 2017
@appleboy
Copy link
Member

LGTM

@tboerger tboerger added the lgtm/need 1 This PR needs approval from one additional maintainer to be merged. label Feb 13, 2017
models/org.go Outdated
@@ -563,18 +563,22 @@ func (org *User) getUserTeams(e Engine, userID int64, cols ...string) ([]*Team,
Find(&teams)
}

func (org *User) getOrgTeamIDs(e Engine, userID int64) ([]int64, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Should this be getUserTeamIDs (to match GetUserTeamIDs)?

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

models/org.go Outdated
Join("INNER", "team_user", "`team_user`.team_id = team.id").
Join("INNER", "user", "`user`.id=team_user.uid").
And("`team_user`.uid = ?", userID).
Asc("`user`.name").
Copy link
Member

Choose a reason for hiding this comment

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

Why is this ORDER BY necessary? We are only looking for one user (i.e. the user with ID userID)

Plus, if we get rid of the ORDER BY, we won't need to join with the user table 😄

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

@ethantkoenig
Copy link
Member

LGTM

@tboerger tboerger 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 Feb 14, 2017
@lunny lunny merged commit 55ae782 into go-gitea:master Feb 14, 2017
@lunny lunny deleted the lunny/small_optimization_getTeamIDs branch February 14, 2017 03:46
@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/refactoring Existing code has been cleaned up. There should be no new functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants