Prevent duplicate records in organizations list when creating a repository#11303
Merged
zeripath merged 10 commits intoMay 7, 2020
Merged
Conversation
prefent dubble entrys
Member
Author
|
I think I hit another xorm issue :(
|
6543
commented
May 5, 2020
Contributor
|
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. |
lafriks
reviewed
May 5, 2020
zeripath
reviewed
May 5, 2020
zeripath
approved these changes
May 5, 2020
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.
|
Member
|
I would prefer that builder would be used to build subselect to be passed to in condition |
Member
Author
|
@lafriks done |
lafriks
reviewed
May 5, 2020
Member
Author
|
something with the CI unrelated went wrong |
zeripath
approved these changes
May 6, 2020
lunny
approved these changes
May 7, 2020
Member
|
Please send back port to v1.11 |
Member
Author
|
BP now :) |
6543
added a commit
to 6543-forks/gitea
that referenced
this pull request
May 7, 2020
…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>
Member
Author
|
-> #11325 |
zeripath
added a commit
that referenced
this pull request
May 7, 2020
…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>
ydelafollye
pushed a commit
to ydelafollye/gitea
that referenced
this pull request
Jul 31, 2020
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
prevent double entries in results of
GetOrgsCanCreateRepoByUserIDI 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