@@ -112,7 +112,6 @@ type User struct {
112112 LoginName string
113113 Type UserType
114114 OwnedOrgs []* User `xorm:"-"`
115- Orgs []* User `xorm:"-"`
116115 Repos []* Repository `xorm:"-"`
117116 Location string
118117 Website string
@@ -603,58 +602,6 @@ func (u *User) GetOwnedOrganizations() (err error) {
603602 return err
604603}
605604
606- // GetOrganizations returns paginated organizations that user belongs to.
607- // TODO: does not respect All and show orgs you privately participate
608- func (u * User ) GetOrganizations (opts * SearchOrganizationsOptions ) error {
609- sess := x .NewSession ()
610- defer sess .Close ()
611-
612- schema , err := x .TableInfo (new (User ))
613- if err != nil {
614- return err
615- }
616- groupByCols := & strings.Builder {}
617- for _ , col := range schema .Columns () {
618- fmt .Fprintf (groupByCols , "`%s`.%s," , schema .Name , col .Name )
619- }
620- groupByStr := groupByCols .String ()
621- groupByStr = groupByStr [0 : len (groupByStr )- 1 ]
622-
623- sess .Select ("`user`.*, count(repo_id) as org_count" ).
624- Table ("user" ).
625- Join ("INNER" , "org_user" , "`org_user`.org_id=`user`.id" ).
626- Join ("LEFT" , builder .
627- Select ("id as repo_id, owner_id as repo_owner_id" ).
628- From ("repository" ).
629- Where (accessibleRepositoryCondition (u )), "`repository`.repo_owner_id = `org_user`.org_id" ).
630- And ("`org_user`.uid=?" , u .ID ).
631- GroupBy (groupByStr )
632- if opts .PageSize != 0 {
633- sess = opts .setSessionPagination (sess )
634- }
635- type OrgCount struct {
636- User `xorm:"extends"`
637- OrgCount int
638- }
639- orgCounts := make ([]* OrgCount , 0 , 10 )
640-
641- if err := sess .
642- Asc ("`user`.name" ).
643- Find (& orgCounts ); err != nil {
644- return err
645- }
646-
647- orgs := make ([]* User , len (orgCounts ))
648- for i , orgCount := range orgCounts {
649- orgCount .User .NumRepos = orgCount .OrgCount
650- orgs [i ] = & orgCount .User
651- }
652-
653- u .Orgs = orgs
654-
655- return nil
656- }
657-
658605// DisplayName returns full name if it's not empty,
659606// returns username otherwise.
660607func (u * User ) DisplayName () string {
0 commit comments