summaryrefslogtreecommitdiffstats
path: root/models/user.go
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2021-06-18 19:00:53 +0200
committerGitHub <noreply@github.com>2021-06-18 19:00:53 +0200
commit889dea8fc1e78b0d915b27f122df116e7296336d (patch)
treef0c6d455c84759281abd507b01a5f02f66e380c8 /models/user.go
parent59f25587e84e99c1c569d6149b9a3b8fb06641f2 (diff)
downloadgitea-889dea8fc1e78b0d915b27f122df116e7296336d.tar.gz
gitea-889dea8fc1e78b0d915b27f122df116e7296336d.zip
Remove User.GetOrganizations() (#14032)
as title
Diffstat (limited to 'models/user.go')
-rw-r--r--models/user.go53
1 files changed, 0 insertions, 53 deletions
diff --git a/models/user.go b/models/user.go
index 002c050651..5998341422 100644
--- a/models/user.go
+++ b/models/user.go
@@ -112,7 +112,6 @@ type User struct {
LoginName string
Type UserType
OwnedOrgs []*User `xorm:"-"`
- Orgs []*User `xorm:"-"`
Repos []*Repository `xorm:"-"`
Location string
Website string
@@ -603,58 +602,6 @@ func (u *User) GetOwnedOrganizations() (err error) {
return err
}
-// GetOrganizations returns paginated organizations that user belongs to.
-// TODO: does not respect All and show orgs you privately participate
-func (u *User) GetOrganizations(opts *SearchOrganizationsOptions) error {
- sess := x.NewSession()
- defer sess.Close()
-
- schema, err := x.TableInfo(new(User))
- if err != nil {
- return err
- }
- groupByCols := &strings.Builder{}
- for _, col := range schema.Columns() {
- fmt.Fprintf(groupByCols, "`%s`.%s,", schema.Name, col.Name)
- }
- groupByStr := groupByCols.String()
- groupByStr = groupByStr[0 : len(groupByStr)-1]
-
- sess.Select("`user`.*, count(repo_id) as org_count").
- Table("user").
- Join("INNER", "org_user", "`org_user`.org_id=`user`.id").
- Join("LEFT", builder.
- Select("id as repo_id, owner_id as repo_owner_id").
- From("repository").
- Where(accessibleRepositoryCondition(u)), "`repository`.repo_owner_id = `org_user`.org_id").
- And("`org_user`.uid=?", u.ID).
- GroupBy(groupByStr)
- if opts.PageSize != 0 {
- sess = opts.setSessionPagination(sess)
- }
- type OrgCount struct {
- User `xorm:"extends"`
- OrgCount int
- }
- orgCounts := make([]*OrgCount, 0, 10)
-
- if err := sess.
- Asc("`user`.name").
- Find(&orgCounts); err != nil {
- return err
- }
-
- orgs := make([]*User, len(orgCounts))
- for i, orgCount := range orgCounts {
- orgCount.User.NumRepos = orgCount.OrgCount
- orgs[i] = &orgCount.User
- }
-
- u.Orgs = orgs
-
- return nil
-}
-
// DisplayName returns full name if it's not empty,
// returns username otherwise.
func (u *User) DisplayName() string {