From 78c8c1ba988b8779401811674dfb7dc9aaa73acf Mon Sep 17 00:00:00 2001 From: Liam Date: Tue, 29 Oct 2024 18:48:09 +0000 Subject: [PATCH] add some optimization --- projects/backend/src/service/score.service.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/projects/backend/src/service/score.service.ts b/projects/backend/src/service/score.service.ts index 0622bce..923a8ba 100644 --- a/projects/backend/src/service/score.service.ts +++ b/projects/backend/src/service/score.service.ts @@ -363,17 +363,18 @@ export class ScoreService { }; } - const additionalData = await ScoreService.getAdditionalScoreData( - score.playerId, - leaderboard.songHash, - `${leaderboard.difficulty.difficulty}-${leaderboard.difficulty.characteristic}`, - score.score - ); + const [additionalData, previousScore] = await Promise.all([ + this.getAdditionalScoreData( + score.playerId, + leaderboard.songHash, + `${leaderboard.difficulty.difficulty}-${leaderboard.difficulty.characteristic}`, + score.score + ), + this.getPreviousScore(score.playerId, leaderboard.id + "", score.timestamp), + ]); if (additionalData) { score.additionalData = additionalData; } - - const previousScore = await this.getPreviousScore(score.playerId, leaderboard.id + "", score.timestamp); if (previousScore) { score.previousScore = previousScore; }