Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
Lamarcke committed Jul 10, 2024
1 parent 82e6c06 commit 44d2849
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/profile/profile-statistics/profile-metrics.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
import { GamePlaytime } from "../../sync/hltb/entity/game-playtime.entity";
import { GameRepositoryService } from "../../game/game-repository/game-repository.service";
import { Game } from "../../game/game-repository/entities/game.entity";
import { toMap } from "../../utils/toMap";

@Injectable()
export class ProfileMetricsService {
Expand All @@ -32,10 +33,7 @@ export class ProfileMetricsService {
): Promise<Map<number, GamePlaytime>> {
const playtimes = await this.htlbService.findAllByGameIds(gameIds);

return playtimes.reduce((acc, curr) => {
acc.set(curr.gameId, curr);
return acc;
}, new Map<number, GamePlaytime>());
return toMap(playtimes, "gameId");
}

async getStatsOverview(userId: string): Promise<ProfileMetricsOverviewDto> {
Expand Down Expand Up @@ -145,10 +143,7 @@ export class ProfileMetricsService {

const playtimesMap = await this.getPlaytimeForGames(gamesIds);

const gamesMap = games.reduce((acc, curr) => {
acc.set(curr.id, curr);
return acc;
}, new Map<number, Game>());
const gamesMap = toMap(games, "id");

for (const entry of collectionEntries) {
const relatedGame = gamesMap.get(entry.gameId);
Expand Down

0 comments on commit 44d2849

Please sign in to comment.