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

Lazy Request (opcode 14) ordering fix #1198

Merged
Merged
Changes from all commits
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
7 changes: 3 additions & 4 deletions src/gateway/opcodes/LazyRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ async function getMembers(guild_id: string, range: [number, number]) {
if (!Array.isArray(range) || range.length !== 2) {
throw new Error("range is not a valid array");
}
// TODO: wait for typeorm to implement ordering for .find queries https://github.com/typeorm/typeorm/issues/2620

let members: Member[] = [];
try {
Expand All @@ -82,11 +81,11 @@ async function getMembers(guild_id: string, range: [number, number]) {
.leftJoinAndSelect("user.sessions", "session")
.addSelect("user.settings")
.addSelect(
"CASE WHEN session.status = 'offline' THEN 0 ELSE 1 END",
"CASE WHEN session.status IS NULL OR session.status = 'offline' OR session.status = 'invisible' THEN 0 ELSE 1 END",
"_status",
)
.orderBy("role.position", "DESC")
.addOrderBy("_status", "DESC")
.orderBy("_status", "DESC")
.addOrderBy("role.position", "DESC")
.addOrderBy("user.username", "ASC")
.offset(Number(range[0]) || 0)
.limit(Number(range[1]) || 100)
Expand Down
Loading