Skip to content

Commit 931c02d

Browse files
Add order by for assignee no sort issue (#20053)
Co-authored-by: wxiaoguang <[email protected]>
1 parent f85bb6f commit 931c02d

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

Diff for: models/issues/issue_list.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ func (issues IssueList) loadAssignees(ctx context.Context) error {
242242
}
243243
rows, err := db.GetEngine(ctx).Table("issue_assignees").
244244
Join("INNER", "`user`", "`user`.id = `issue_assignees`.assignee_id").
245-
In("`issue_assignees`.issue_id", issueIDs[:limit]).
245+
In("`issue_assignees`.issue_id", issueIDs[:limit]).OrderBy(user_model.GetOrderByName()).
246246
Rows(new(AssigneeIssue))
247247
if err != nil {
248248
return err

Diff for: models/organization/team_repo.go

+1
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,6 @@ func GetTeamsWithAccessToRepo(ctx context.Context, orgID, repoID int64, mode per
8181
Join("INNER", "team_repo", "team_repo.team_id = team.id").
8282
And("team_repo.org_id = ?", orgID).
8383
And("team_repo.repo_id = ?", repoID).
84+
OrderBy("name").
8485
Find(&teams)
8586
}

Diff for: models/repo/user_repo.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func GetRepoAssignees(ctx context.Context, repo *Repository) (_ []*user_model.Us
109109
// and just waste 1 unit is cheaper than re-allocate memory once.
110110
users := make([]*user_model.User, 0, len(userIDs)+1)
111111
if len(userIDs) > 0 {
112-
if err = e.In("id", userIDs).Find(&users); err != nil {
112+
if err = e.In("id", userIDs).OrderBy(user_model.GetOrderByName()).Find(&users); err != nil {
113113
return nil, err
114114
}
115115
}
@@ -168,5 +168,5 @@ func GetReviewers(ctx context.Context, repo *Repository, doerID, posterID int64)
168168
}
169169

170170
users := make([]*user_model.User, 0, 8)
171-
return users, db.GetEngine(ctx).Where(cond).OrderBy("name").Find(&users)
171+
return users, db.GetEngine(ctx).Where(cond).OrderBy(user_model.GetOrderByName()).Find(&users)
172172
}

Diff for: models/user/user.go

+7
Original file line numberDiff line numberDiff line change
@@ -1314,3 +1314,10 @@ func IsUserVisibleToViewer(ctx context.Context, u, viewer *User) bool {
13141314
}
13151315
return false
13161316
}
1317+
1318+
func GetOrderByName() string {
1319+
if setting.UI.DefaultShowFullName {
1320+
return "full_name, name"
1321+
}
1322+
return "name"
1323+
}

0 commit comments

Comments
 (0)