feat: add match game detail analytics
This commit is contained in:
1 parent
c6da2013bd
commit
7b5604873e
18 files changed
+3452
-46
No files matched your search
@@ -205,7 +205,7 @@ export class CommunityStatsService {
|
||||
communityId: mongoose.Types.ObjectId;
|
||||
matchId: mongoose.Types.ObjectId;
|
||||
}): Promise<InternalMatchDetailResponse> {
|
||||
const key = `riot:communitystats:matchDetail:${params.communityId.toString()}:${params.matchId.toString()}`;
|
||||
const key = `riot:communitystats:matchDetail:v${MATCH_STATS_BUILDER_VERSION}:${params.communityId.toString()}:${params.matchId.toString()}`;
|
||||
const cached =
|
||||
await this.cacheService.get<InternalMatchDetailResponse>(key);
|
||||
if (cached) return cached;
|
||||
@@ -217,19 +217,33 @@ export class CommunityStatsService {
|
||||
(item) => item.matchId === params.matchId.toString(),
|
||||
);
|
||||
if (!match) throw new NotFoundException('Internal match not found.');
|
||||
let gameDetails = dataset.detailsByMatchId.get(match.matchId) ?? [];
|
||||
if (gameDetails.some((game) => game.timelineLoaded !== true)) {
|
||||
await this.matchStatsService.buildAndUpsert(params.matchId, {
|
||||
includeTimeline: true,
|
||||
});
|
||||
const refreshedDataset = await this.buildBaseDataset(params.communityId, {
|
||||
seasonId: 'all',
|
||||
});
|
||||
gameDetails = refreshedDataset.detailsByMatchId.get(match.matchId) ?? [];
|
||||
}
|
||||
const response: InternalMatchDetailResponse = {
|
||||
match,
|
||||
games: (dataset.detailsByMatchId.get(match.matchId) ?? []).map(
|
||||
games: gameDetails.map(
|
||||
(game) => ({
|
||||
gameNumber: game.gameNumber,
|
||||
riotMatchId: game.riotMatchId,
|
||||
gameCreation: game.gameCreation,
|
||||
gameDuration: game.gameDuration,
|
||||
gameVersion: game.gameVersion,
|
||||
timeline: game.timeline ?? [],
|
||||
objectiveEvents: game.objectiveEvents ?? [],
|
||||
teams: game.teams.map((team) => ({
|
||||
teamIndex: team.teamIndex,
|
||||
side: team.side,
|
||||
win: team.win,
|
||||
objectives: team.objectives,
|
||||
bans: team.bans ?? [],
|
||||
participants: team.participants.map((record) => ({
|
||||
userId: record.userId,
|
||||
summonerName: record.summonerName,
|
||||
@@ -237,6 +251,7 @@ export class CommunityStatsService {
|
||||
side: record.side,
|
||||
teamPosition: record.teamPosition,
|
||||
championId: record.championId,
|
||||
championLevel: record.championLevel,
|
||||
kills: record.kills,
|
||||
deaths: record.deaths,
|
||||
assists: record.assists,
|
||||
@@ -245,13 +260,21 @@ export class CommunityStatsService {
|
||||
gold: record.gold,
|
||||
gpm: record.gpm,
|
||||
damageDealtToChampions: record.damageDealtToChampions,
|
||||
damageTaken: record.damageTaken,
|
||||
damageShare: record.damageShare,
|
||||
killParticipation: record.killParticipation,
|
||||
visionScore: record.visionScore,
|
||||
wardsPlaced: record.wardsPlaced,
|
||||
wardsKilled: record.wardsKilled,
|
||||
controlWardsBought: record.controlWardsBought,
|
||||
firstBloodKill: record.firstBloodKill ?? false,
|
||||
firstBloodAssist: record.firstBloodAssist ?? false,
|
||||
items: record.items,
|
||||
trinket: record.trinket,
|
||||
summonerSpells: record.summonerSpells,
|
||||
perks: record.perks,
|
||||
itemBuild: record.itemBuild ?? [],
|
||||
skillBuild: record.skillBuild ?? [],
|
||||
win: record.win,
|
||||
})),
|
||||
})),
|
||||
|
||||
Reference in new issue
Block a user