Skip to content
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

Add order by for assignee no sort issue #20053

Merged
merged 8 commits into from
Jul 14, 2022
2 changes: 1 addition & 1 deletion models/issues/issue_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func (issues IssueList) loadAssignees(ctx context.Context) error {
}
rows, err := db.GetEngine(ctx).Table("issue_assignees").
Join("INNER", "`user`", "`user`.id = `issue_assignees`.assignee_id").
In("`issue_assignees`.issue_id", issueIDs[:limit]).
In("`issue_assignees`.issue_id", issueIDs[:limit]).OrderBy(user_model.GetOrderBy()).
wxiaoguang marked this conversation as resolved.
Show resolved Hide resolved
Rows(new(AssigneeIssue))
if err != nil {
return err
Expand Down
1 change: 1 addition & 0 deletions models/organization/team_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,6 @@ func GetTeamsWithAccessToRepo(ctx context.Context, orgID, repoID int64, mode per
Join("INNER", "team_repo", "team_repo.team_id = team.id").
And("team_repo.org_id = ?", orgID).
And("team_repo.repo_id = ?", repoID).
OrderBy("name").
6543 marked this conversation as resolved.
Show resolved Hide resolved
6543 marked this conversation as resolved.
Show resolved Hide resolved
Find(&teams)
}
4 changes: 2 additions & 2 deletions models/repo/user_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func GetRepoAssignees(ctx context.Context, repo *Repository) (_ []*user_model.Us
// and just waste 1 unit is cheaper than re-allocate memory once.
users := make([]*user_model.User, 0, len(userIDs)+1)
if len(userIDs) > 0 {
if err = e.In("id", userIDs).Find(&users); err != nil {
if err = e.In("id", userIDs).OrderBy(user_model.GetOrderBy()).Find(&users); err != nil {
wxiaoguang marked this conversation as resolved.
Show resolved Hide resolved
return nil, err
}
}
Expand Down Expand Up @@ -168,5 +168,5 @@ func GetReviewers(ctx context.Context, repo *Repository, doerID, posterID int64)
}

users := make([]*user_model.User, 0, 8)
return users, db.GetEngine(ctx).Where(cond).OrderBy("name").Find(&users)
return users, db.GetEngine(ctx).Where(cond).OrderBy(user_model.GetOrderBy()).Find(&users)
wxiaoguang marked this conversation as resolved.
Show resolved Hide resolved
}
7 changes: 7 additions & 0 deletions models/user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -1270,3 +1270,10 @@ func IsUserVisibleToViewer(ctx context.Context, u, viewer *User) bool {
}
return false
}

func GetOrderBy() string {
wxiaoguang marked this conversation as resolved.
Show resolved Hide resolved
if setting.UI.DefaultShowFullName {
return "full_name"
tyroneyeh marked this conversation as resolved.
Show resolved Hide resolved
}
return "name"
}