Skip to content

Commit fc08f70

Browse files
committed
Some slight improvements
1 parent bf046b1 commit fc08f70

File tree

5 files changed

+19
-9
lines changed

5 files changed

+19
-9
lines changed

src/gameserver/command/ProcessRankedMatch/process-ranked-match.handler.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ export class ProcessRankedMatchHandler
2525
{
2626
private static readonly Slogger = new Logger(ProcessRankedMatchHandler.name);
2727

28+
public static TOTAL_CALIBRATION_GAMES = 10;
29+
2830
private readonly logger = ProcessRankedMatchHandler.Slogger;
2931

3032
public static readonly AVERAGE_DIFF_CAP = 300;
@@ -232,7 +234,7 @@ export class ProcessRankedMatchHandler
232234
cb,
233235
winner,
234236
mmrDiff,
235-
10, // CB GAMES = 0 for now
237+
ProcessRankedMatchHandler.TOTAL_CALIBRATION_GAMES, // CB GAMES = 0 for now
236238
25,
237239
0,
238240
),

src/gameserver/model/leaderboard.view.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ select p.steam_id,
2020
avg(pim.deaths)::float as deaths,
2121
avg(pim.assists)::float as assists,
2222
sum(m.duration)::int as play_time,
23-
sum((m.matchmaking_mode = 0)::int) as ranked_games,
23+
sum((m.matchmaking_mode in (0, 1))::int) as ranked_games,
2424
(row_number() over ( order by p.mmr desc))::int as rank
2525
from cte p
2626
inner join player_in_match pim on pim."playerId" = p.steam_id

src/rest/dto/player.dto.ts

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export class LeaderboardEntryPageDto extends Page<LeaderboardEntryDto> {
2929
export class PlayerSummaryDto extends LeaderboardEntryDto {
3030
newbieUnrankedGamesLeft: number;
3131
playedAnyGame: boolean;
32+
calibrationGamesLeft: number;
3233
}
3334

3435
export class BanStatusDto {

src/rest/player.controller.ts

+7
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import { AchievementDto } from 'rest/dto/achievement.dto';
3333
import PlayerInMatchEntity from 'gameserver/model/player-in-match.entity';
3434
import FinishedMatchEntity from 'gameserver/model/finished-match.entity';
3535
import { makePage } from 'gateway/util/make-page';
36+
import { ProcessRankedMatchHandler } from 'gameserver/command/ProcessRankedMatch/process-ranked-match.handler';
3637

3738
@Controller('player')
3839
@ApiTags('player')
@@ -185,6 +186,8 @@ offset $2 limit $3`,
185186
lb.ranked_games > 0
186187
? 0
187188
: Math.max(0, UNRANKED_GAMES_REQUIRED_FOR_RANKED - lb.games),
189+
190+
calibrationGamesLeft: Math.max(ProcessRankedMatchHandler.TOTAL_CALIBRATION_GAMES - lb.ranked_games, 0)
188191
};
189192
}
190193

@@ -194,6 +197,8 @@ offset $2 limit $3`,
194197

195198
const rank = await this.playerService.getRank(version, steam_id);
196199

200+
console.log(summary.ranked_games)
201+
197202
return {
198203
rank: rank,
199204
mmr: summary?.mmr,
@@ -217,6 +222,8 @@ offset $2 limit $3`,
217222
UNRANKED_GAMES_REQUIRED_FOR_RANKED -
218223
(summary?.unranked_games || 0),
219224
),
225+
226+
calibrationGamesLeft: Math.max(ProcessRankedMatchHandler.TOTAL_CALIBRATION_GAMES - (summary?.ranked_games || 0), 0)
220227
};
221228
}
222229

src/rest/service/player.service.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ import { VersionPlayerEntity } from 'gameserver/model/version-player.entity';
1212

1313
export type Summary =
1414
| undefined
15-
| (Omit<PlayerSummaryDto, 'rank' | 'newbieUnrankedGamesLeft'> & {
15+
| (Omit<PlayerSummaryDto, "rank" | "newbieUnrankedGamesLeft"> & {
1616
ranked_games: number;
1717
unranked_games: number;
18-
any_games: number;
18+
any_games: number;
1919
});
2020

2121
// TODO: we probably need to orm this shit up
@@ -30,7 +30,7 @@ export class PlayerService {
3030
private readonly connection: Connection,
3131
) {}
3232

33-
@cached(100, 'getRank')
33+
@cached(100, "getRank")
3434
public async getRank(
3535
version: Dota2Version,
3636
steam_id: string,
@@ -77,7 +77,7 @@ where p.mmr > $3
7777
return rank2[0].count + 1;
7878
}
7979

80-
@cached(100, 'heroStats')
80+
@cached(100, "heroStats")
8181
async heroStats(
8282
version: Dota2Version,
8383
steam_id: string,
@@ -103,7 +103,7 @@ group by pim.hero, pim."playerId"
103103
);
104104
}
105105

106-
@cached(100, 'winrateLastRankedGames')
106+
@cached(100, "winrateLastRankedGames")
107107
async winrateLastRankedGames(steam_id: string): Promise<number> {
108108
const some: { is_win: boolean }[] = await this.playerInMatchRepository
109109
.query(`
@@ -178,13 +178,13 @@ select p.steam_id,
178178
avg(pim.deaths)::float as deaths,
179179
avg(pim.assists)::float as assists,
180180
sum(m.duration)::int as play_time,
181-
sum((m.matchmaking_mode = 0)::int) as ranked_games,
181+
sum((m.matchmaking_mode in ($2, $3))::int) as ranked_games,
182182
-1 as rank
183183
from cte p
184184
inner join player_in_match pim on pim."playerId" = p.steam_id
185185
inner join finished_match m on pim."matchId" = m.id
186186
group by p.steam_id, p.recent_ranked_games, p.mmr, p.games, p.wins, p.any_games`,
187-
[steam_id],
187+
[steam_id, MatchmakingMode.RANKED, MatchmakingMode.UNRANKED],
188188
);
189189

190190
return some[0];

0 commit comments

Comments
 (0)