Skip to content

Commit fe8bfa5

Browse files
0xBAADF00Dstrk
authored andcommitted
Ordering team by name ascending except for 'Owners' (#48)
1 parent d318f61 commit fe8bfa5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

models/org.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func (org *User) GetOwnerTeam() (*Team, error) {
5050
}
5151

5252
func (org *User) getTeams(e Engine) error {
53-
return e.Where("org_id=?", org.ID).Find(&org.Teams)
53+
return e.Where("org_id=?", org.ID).OrderBy("CASE WHEN name LIKE '" + OWNER_TEAM + "' THEN '' ELSE name END").Find(&org.Teams)
5454
}
5555

5656
// GetTeams returns all teams that belong to organization.
@@ -495,7 +495,7 @@ func (org *User) GetUserRepositories(userID int64, page, pageSize int) ([]*Repos
495495
repos := make([]*Repository, 0, pageSize)
496496
// FIXME: use XORM chain operations instead of raw SQL.
497497
if err = x.Sql(fmt.Sprintf(`SELECT repository.* FROM repository
498-
INNER JOIN team_repo
498+
INNER JOIN team_repo
499499
ON team_repo.repo_id = repository.id
500500
WHERE (repository.owner_id = ? AND repository.is_private = ?) OR team_repo.team_id IN (%s)
501501
GROUP BY repository.id
@@ -507,7 +507,7 @@ func (org *User) GetUserRepositories(userID int64, page, pageSize int) ([]*Repos
507507
}
508508

509509
results, err := x.Query(fmt.Sprintf(`SELECT repository.id FROM repository
510-
INNER JOIN team_repo
510+
INNER JOIN team_repo
511511
ON team_repo.repo_id = repository.id
512512
WHERE (repository.owner_id = ? AND repository.is_private = ?) OR team_repo.team_id IN (%s)
513513
GROUP BY repository.id
@@ -534,7 +534,7 @@ func (org *User) GetUserMirrorRepositories(userID int64) ([]*Repository, error)
534534

535535
repos := make([]*Repository, 0, 10)
536536
if err = x.Sql(fmt.Sprintf(`SELECT repository.* FROM repository
537-
INNER JOIN team_repo
537+
INNER JOIN team_repo
538538
ON team_repo.repo_id = repository.id AND repository.is_mirror = ?
539539
WHERE (repository.owner_id = ? AND repository.is_private = ?) OR team_repo.team_id IN (%s)
540540
GROUP BY repository.id

0 commit comments

Comments
 (0)