diff options
author | ᴜɴᴋɴᴡᴏɴ <u@gogs.io> | 2020-08-17 21:09:22 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-17 21:09:22 +0800 |
commit | f3993b9cdb250c958c88cdfe1dfaf3de9cbad0dc (patch) | |
tree | ddac2c10e4644c871797c87cee4480d68580bf54 /internal/db | |
parent | a961afe52bf94f71e917e05e366a4b71834a2e84 (diff) |
organization: limit showing at most 12 members in profile page (#6254)
Diffstat (limited to 'internal/db')
-rw-r--r-- | internal/db/issue.go | 2 | ||||
-rw-r--r-- | internal/db/org.go | 17 |
2 files changed, 12 insertions, 7 deletions
diff --git a/internal/db/issue.go b/internal/db/issue.go index 6347c99d..8a90fe19 100644 --- a/internal/db/issue.go +++ b/internal/db/issue.go @@ -1173,7 +1173,7 @@ func updateIssueMentions(e Engine, issueID int64, mentions []string) error { } memberIDs := make([]int64, 0, user.NumMembers) - orgUsers, err := getOrgUsersByOrgID(e, user.ID) + orgUsers, err := getOrgUsersByOrgID(e, user.ID, 0) if err != nil { return fmt.Errorf("getOrgUsersByOrgID [%d]: %v", user.ID, err) } diff --git a/internal/db/org.go b/internal/db/org.go index f235928b..1f043bec 100644 --- a/internal/db/org.go +++ b/internal/db/org.go @@ -64,8 +64,8 @@ func (org *User) TeamsHaveAccessToRepo(repoID int64, mode AccessMode) ([]*Team, } // GetMembers returns all members of organization. -func (org *User) GetMembers() error { - ous, err := GetOrgUsersByOrgID(org.ID) +func (org *User) GetMembers(limit int) error { + ous, err := GetOrgUsersByOrgID(org.ID, limit) if err != nil { return err } @@ -315,14 +315,19 @@ func GetOrgIDsByUserID(userID int64, showPrivate bool) ([]int64, error) { return orgIDs, sess.Distinct("org_id").Find(&orgIDs) } -func getOrgUsersByOrgID(e Engine, orgID int64) ([]*OrgUser, error) { +func getOrgUsersByOrgID(e Engine, orgID int64, limit int) ([]*OrgUser, error) { orgUsers := make([]*OrgUser, 0, 10) - return orgUsers, e.Where("org_id=?", orgID).Find(&orgUsers) + + sess := e.Where("org_id=?", orgID) + if limit > 0 { + sess = sess.Limit(limit) + } + return orgUsers, sess.Find(&orgUsers) } // GetOrgUsersByOrgID returns all organization-user relations by organization ID. -func GetOrgUsersByOrgID(orgID int64) ([]*OrgUser, error) { - return getOrgUsersByOrgID(x, orgID) +func GetOrgUsersByOrgID(orgID int64, limit int) ([]*OrgUser, error) { + return getOrgUsersByOrgID(x, orgID, limit) } // ChangeOrgUserStatus changes public or private membership status. |