-
-
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
Prevent duplicate records in organizations list when creating a repository #11303
Prevent duplicate records in organizations list when creating a repository #11303
Conversation
prefent dubble entrys
I think I hit another xorm issue :(
|
How about: // GetOrgsCanCreateRepoByUserID returns a list of organizations where given user ID
// are allowed to create repos.
func GetOrgsCanCreateRepoByUserID(userID int64) ([]*User, error) {
orgs := make([]*User, 0, 10)
return orgs, x.Where("id IN ("+
"SELECT `user`.id FROM `user` "+
"INNER JOIN `team_user` ON `team_user`.org_id = `user`.id "+
"INNER JOIN `team` on `team`.id = `team_user`.team_id "+
"WHERE `team_user`.uid = ? AND "+
"(`team`.authorize = ? OR `team`.can_create_org_repo = ?) "+
"GROUP BY `user`.id)", userID, AccessModeOwner, true).
Desc("`user`.updated_unix").
Find(&orgs)
} Fixed some spelling mistakes on my behalf. |
Codecov Report
@@ Coverage Diff @@
## master #11303 +/- ##
==========================================
+ Coverage 43.82% 43.85% +0.03%
==========================================
Files 607 607
Lines 86899 86902 +3
==========================================
+ Hits 38080 38115 +35
+ Misses 44115 44084 -31
+ Partials 4704 4703 -1
Continue to review full report at Codecov.
|
I would prefer that builder would be used to build subselect to be passed to in condition |
@lafriks done |
something with the CI unrelated went wrong |
Please send back port to v1.11 |
BP now :) |
…o-gitea#11303) prevent double entries in results of GetOrgsCanCreateRepoByUserID I first try to only add GroupBy directly but xorm return broken user objects ... ... solution was to just query related UserIDs(OrgIDs) first and return OrgUsers based on this IDs close go-gitea#11258 Co-authored-by: zeripath <art27@cantab.net>
-> #11325 |
…11303) (#11325) Backport #11303 Prevent multiple listings of organization when creating a repository (#11303) prevent double entries in results of GetOrgsCanCreateRepoByUserID I first try to only add GroupBy directly but xorm return broken user objects ... ... solution was to just query related UserIDs(OrgIDs) first and return OrgUsers based on this IDs close #11258 Co-authored-by: zeripath <art27@cantab.net>
…o-gitea#11303) prevent double entries in results of GetOrgsCanCreateRepoByUserID I first try to only add GroupBy directly but xorm return broken user objects ... ... solution was to just query related UserIDs(OrgIDs) first and return OrgUsers based on this IDs close go-gitea#11258 Co-authored-by: zeripath <art27@cantab.net>
prevent double entries in results of
GetOrgsCanCreateRepoByUserID
I first try to only add GroupBy directly but xorm return broken user objects ...
... solution was to just query related UserIDs(OrgIDs) first and return OrgUsers based on this IDs
close #11258