diff --git a/back/volume/src/pong/pong.service.ts b/back/volume/src/pong/pong.service.ts index 1ea8201..989342e 100644 --- a/back/volume/src/pong/pong.service.ts +++ b/back/volume/src/pong/pong.service.ts @@ -49,9 +49,12 @@ export class PongService { await this.updatePlayer(1, result) } - async getHistory (ranked: boolean): Promise { + async getRankedHistory (): Promise { return await this.resultsRepository.find({ - where: { ranked }, + where: { ranked: true}, + relations: { + players: true, + }, order: { date: 'DESC' } }) } diff --git a/back/volume/src/users/users.controller.ts b/back/volume/src/users/users.controller.ts index 9762b9f..899c695 100644 --- a/back/volume/src/users/users.controller.ts +++ b/back/volume/src/users/users.controller.ts @@ -76,7 +76,7 @@ export class UsersController { @Get('rankedHistory') @UseGuards(AuthenticatedGuard) async getRankedHistory (): Promise { - return await this.pongService.getHistory(true) + return await this.pongService.getRankedHistory() } @Get('history/:id') diff --git a/back/volume/src/users/users.service.ts b/back/volume/src/users/users.service.ts index 80d90f0..7526dd0 100644 --- a/back/volume/src/users/users.service.ts +++ b/back/volume/src/users/users.service.ts @@ -131,12 +131,15 @@ export class UsersService { }, }); return leaderboard.filter((user) => user.rank !== 0); - } async getRank(ftId: number): Promise { - const leader = await this.getLeaderboard(); - return leader.findIndex((user) => user.ftId === ftId); + let leaderboard = await this.usersRepository.find({ + order: { + winrate: "DESC", + }, + }); + return leaderboard.findIndex((user) => user.ftId === ftId); } async invit(ftId: number, targetFtId: number): Promise { diff --git a/front/volume/src/App.svelte b/front/volume/src/App.svelte index f2c7126..552c6fd 100644 --- a/front/volume/src/App.svelte +++ b/front/volume/src/App.svelte @@ -87,7 +87,7 @@ } export async function getHistory(): Promise> { - let response = await fetch(API_URL + "/history/" + $store.ftId, { + let response = await fetch(API_URL + "/rankedHistory/", { credentials: "include", mode: "cors", }); diff --git a/front/volume/src/components/MatchHistory.svelte b/front/volume/src/components/MatchHistory.svelte index 032e461..1475701 100644 --- a/front/volume/src/components/MatchHistory.svelte +++ b/front/volume/src/components/MatchHistory.svelte @@ -4,6 +4,7 @@ players: Array; score: Array; date: Date; + ranked: boolean; } diff --git a/front/volume/vite.config.ts b/front/volume/vite.config.ts index 44ad241..df437c3 100644 --- a/front/volume/vite.config.ts +++ b/front/volume/vite.config.ts @@ -1,13 +1,13 @@ -import { defineConfig } from 'vite' -import { svelte } from '@sveltejs/vite-plugin-svelte' +import { defineConfig } from "vite"; +import { svelte } from "@sveltejs/vite-plugin-svelte"; -// https://vitejs.dev/config/ export default defineConfig({ plugins: [svelte()], + appType: "spa", server: { - port: 80 + port: 80, }, preview: { - port: 80 + port: 80, }, -}) +});