Skip to content

db: migrate org.go to organizations.go with GORM #7538

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

Draft
wants to merge 29 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
getOrgUsersByOrgID
  • Loading branch information
unknwon committed Dec 17, 2023
commit 2971cabae143ed23c1acc4dba6c039291fb08f29
5 changes: 3 additions & 2 deletions internal/db/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -1180,12 +1180,13 @@ func updateIssueMentions(e Engine, issueID int64, mentions []string) error {
continue
}

memberIDs := make([]int64, 0, user.NumMembers)
orgUsers, err := getOrgUsersByOrgID(e, user.ID, 0)
orgUsers := make([]*OrgUser, 0, 10)
err := e.Where("org_id=?", user.ID).Find(&orgUsers)
if err != nil {
return fmt.Errorf("getOrgUsersByOrgID [%d]: %v", user.ID, err)
}

memberIDs := make([]int64, 0, user.NumMembers)
for _, orgUser := range orgUsers {
memberIDs = append(memberIDs, orgUser.ID)
}
Expand Down
11 changes: 0 additions & 11 deletions internal/db/org.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,6 @@ import (
"xorm.io/builder"
)

// getOrgUsersByOrgID returns all organization-user relations by organization ID.
func getOrgUsersByOrgID(e Engine, orgID int64, limit int) ([]*OrgUser, error) {
orgUsers := make([]*OrgUser, 0, 10)

sess := e.Where("org_id=?", orgID)
if limit > 0 {
sess = sess.Limit(limit)
}
return orgUsers, sess.Find(&orgUsers)
}

// GetUserMirrorRepositories returns mirror repositories of the organization which the user has access to.
func (u *User) GetUserMirrorRepositories(userID int64) ([]*Repository, error) {
teamIDs, err := u.GetUserTeamIDs(userID)
Expand Down