Skip to content

Commit 7faad67

Browse files
committed
Make 5x5 matches show first
1 parent 4efd8fc commit 7faad67

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/rest/match/live-match.controller.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
import { Observable, scan } from "rxjs";
1717
import { map } from "rxjs/operators";
1818
import { ReqLoggingInterceptor } from "../../middleware/req-logging.interceptor";
19+
import { getLobbyTypePriority } from "../../utils/getLobbyTypePriority";
1920

2021
function wrapSse<A>() {
2122
return (source: A): MessageObjectDto<A> => ({
@@ -31,7 +32,13 @@ export class LiveMatchController {
3132

3233
@Get("/list")
3334
async listMatches(): Promise<LiveMatchDto[]> {
34-
return this.ls.list();
35+
return this.ls
36+
.list()
37+
.sort(
38+
(a, b) =>
39+
getLobbyTypePriority(a.matchmakingMode) -
40+
getLobbyTypePriority(b.matchmakingMode),
41+
);
3542
}
3643

3744
@ApiParam({

src/utils/getLobbyTypePriority.ts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { MatchmakingMode } from "../gateway/shared-types/matchmaking-mode";
2+
3+
export const getLobbyTypePriority = (type: MatchmakingMode): number => {
4+
let score = Number(type);
5+
6+
if (type === MatchmakingMode.UNRANKED) {
7+
score -= 1000;
8+
} else if (type === MatchmakingMode.BOTS_2X2) {
9+
score -= 100;
10+
}
11+
return score;
12+
};

0 commit comments

Comments
 (0)