diff --git a/src/replay/replay.service.ts b/src/replay/replay.service.ts index 43fc0ab8b6ecec8d375e9ee204c6f3f3298fba81..3120ecdb6946b6ddb0b0d7fd40198a3e3dd14a3a 100644 --- a/src/replay/replay.service.ts +++ b/src/replay/replay.service.ts @@ -93,17 +93,25 @@ export class ReplayService { // // this block returns all score data from the game // - let scores = await this.scoreRepository.find({ - where: { faction: In(factionIds) }, - relations: ['faction'], - }); - let currentScore = scores.map(score => { - return { - score: score.score, - timestamp: score.scoreTimeStamp, - faction: score.faction['factionName'], - }; - }); + let currentScore = []; + await Promise.all( + factions.map(async faction => { + let scores = await this.scoreRepository.find({ + where: { faction: faction }, + relations: ['faction'], + }); + currentScore.push( + scores.map(score => { + return { + score: score.score, + timestamp: score.scoreTimeStamp, + faction: score.faction['factionName'], + }; + }), + ); + }), + ); + console.log(currentScore); return { players: currentdata,