diff --git a/client/src/components/SVGContainer.vue b/client/src/components/SVGContainer.vue index 73406fc..698e5fe 100644 --- a/client/src/components/SVGContainer.vue +++ b/client/src/components/SVGContainer.vue @@ -1,5 +1,6 @@ + + + + diff --git a/client/src/components/Summoner/SummonerStats.vue b/client/src/components/Summoner/SummonerStats.vue index d7dc631..22e4a29 100644 --- a/client/src/components/Summoner/SummonerStats.vue +++ b/client/src/components/Summoner/SummonerStats.vue @@ -1,5 +1,5 @@ @@ -109,6 +111,7 @@ import MainFooter from '@/components/MainFooter.vue' import Match from '@/components/Match/Match.vue' import RecentActivity from '@/components/Summoner/RecentActivity.vue' import SearchForm from '@/components/SearchForm.vue' +import SummonerChampions from '@/components/Summoner/SummonerChampions.vue' import SummonerLoader from '@/components/Summoner/SummonerLoader.vue' import SummonerMates from '@/components/Summoner/SummonerMates.vue' import SummonerRanked from '@/components/Summoner/SummonerRanked.vue' @@ -122,6 +125,7 @@ export default { Match, RecentActivity, SearchForm, + SummonerChampions, SummonerLoader, SummonerMates, SummonerRanked, diff --git a/server/app/Helpers/StatsHelper.js b/server/app/Helpers/StatsHelper.js index f4975a2..cea8a81 100644 --- a/server/app/Helpers/StatsHelper.js +++ b/server/app/Helpers/StatsHelper.js @@ -24,6 +24,7 @@ class StatsHelper { }) } } + const championStats = await this.matchRepository.championStats(account.puuid) const championClassStats = await this.matchRepository.championClassStats(account.puuid) const mates = await this.matchRepository.mates(account.puuid, account.name) @@ -33,6 +34,7 @@ class StatsHelper { role: roleStats.sort(this.sortTeamByRole), class: championClassStats, mates, + champion: championStats, } } diff --git a/server/app/Repositories/MatchRepository.js b/server/app/Repositories/MatchRepository.js index ee248f4..05d3c30 100644 --- a/server/app/Repositories/MatchRepository.js +++ b/server/app/Repositories/MatchRepository.js @@ -9,6 +9,43 @@ class MatchRepository { this.Match = Match } + /** + * Get Summoner's statistics for the 5 most played champions + * @param puuid of the summoner + */ + championStats(puuid) { + return this.Match.query().aggregate([ + { + $match: { + summoner_puuid: puuid, + result: { $not: { $eq: 'Remake' } } + } + }, + { + $group: { + _id: "$champion.id", + champion: { $first: "$champion.name" }, + count: { $sum: 1 }, + wins: { + $sum: { + $cond: [{ $eq: ["$result", "Win"] }, 1, 0] + } + }, + losses: { + $sum: { + $cond: [{ $eq: ["$result", "Fail"] }, 1, 0] + } + }, + kills: { $sum: "$stats.kills" }, + deaths: { $sum: "$stats.deaths" }, + assists: { $sum: "$stats.assists" }, + } + }, + { $sort: { 'count': -1 } }, + { $limit: 5 }, + ]) + } + /** * Get Summoner's statistics for all played champion classes * @param puuid of the summoner