Commit 652f755a authored by nanahira's avatar nanahira

env

parent 67ee7b63
Pipeline #25432 passed with stages
in 4 minutes and 8 seconds
...@@ -37,6 +37,35 @@ export class AppService extends ConsoleLogger { ...@@ -37,6 +37,35 @@ export class AppService extends ConsoleLogger {
return new GenericReturnMessageDto(200, 'success', dto); return new GenericReturnMessageDto(200, 'success', dto);
} }
async getMatchResultInv(username: string) {
const [win, total] = await Promise.all([
this.duelLogPlayerRepository
.createQueryBuilder('duelLogPlayer')
.innerJoin('duelLogPlayer.duelLog', 'duelLog')
.innerJoin(
'duelLog.players',
'dealer',
'dealer.realName IN (:...dealerUsernames) and dealer.winner = 0',
{
dealerUsernames: this.dealerUsername,
},
)
.where('duelLogPlayer.realName = :username', { username })
.select('COUNT(duelLogPlayer.id)', 'win')
.getRawOne<{ win: string }>(),
this.duelLogPlayerRepository.count({
where: {
realName: username,
},
}),
]);
const dto = new MatchResultDto();
dto.win = parseInt(win.win) || 0;
dto.total = total || 0;
dto.lose = dto.total - dto.win;
return new GenericReturnMessageDto(200, 'success', dto);
}
async getDealerMatchResult() { async getDealerMatchResult() {
return await this.getMatchResult({ return await this.getMatchResult({
realName: In(this.dealerUsername), realName: In(this.dealerUsername),
...@@ -44,8 +73,6 @@ export class AppService extends ConsoleLogger { ...@@ -44,8 +73,6 @@ export class AppService extends ConsoleLogger {
} }
async getUserMatchResult(username: string) { async getUserMatchResult(username: string) {
return await this.getMatchResult({ return await this.getMatchResultInv(username);
realName: username,
});
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment