Skip to content

feat: sort users by username #7838

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

Merged
merged 4 commits into from
Jun 6, 2023
Merged
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
Address PR comments
  • Loading branch information
mtojek committed Jun 5, 2023
commit 97e52c85587baed0d78a17c02e566ec36fff0d96
2 changes: 1 addition & 1 deletion coderd/database/dbfake/databasefake.go
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,7 @@ func (q *fakeQuerier) GetUsers(_ context.Context, params database.GetUsersParams

// Database orders by username
slices.SortFunc(users, func(a, b database.User) bool {
return sort.StringsAreSorted([]string{a.Username, b.Username})
return a.Username < b.Username
})

// Filter out deleted since they should never be returned..
Expand Down
2 changes: 1 addition & 1 deletion coderd/users_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1694,7 +1694,7 @@ func assertPagination(ctx context.Context, t *testing.T, client *codersdk.Client
// sortUsers sorts by (created_at, id)
func sortUsers(users []codersdk.User) {
sort.Slice(users, func(i, j int) bool {
return sort.StringsAreSorted([]string{users[i].Username, users[j].Username})
return users[i].Username < users[j].Username
})
}

Expand Down