Summoner
W / L
Winrate
@@ -123,14 +123,3 @@ export default {
}
}
-
-
diff --git a/client/src/components/Summoner/SummonerStats.vue b/client/src/components/Summoner/SummonerStats.vue
new file mode 100644
index 0000000..ed2d2a4
--- /dev/null
+++ b/client/src/components/Summoner/SummonerStats.vue
@@ -0,0 +1,184 @@
+
+
+
+
+
+
STATS
+
+
+
+
+
+
+
+
+
Stats based on
+
+ {{ globalStats.count }} matches
+
+
+ Load more matches
+
and refresh the page
+
to have better results.
+
+
+
+
+
+
+
+
+
Stat
+
Total
+
Per min
+
Avg
+
+
+ -
+
{{ name }}
+ {{ stat }}
+ {{ (stat / (globalStats.time / 60)).toFixed(2) }}
+ {{ (stat / globalStats.count).toFixed(2) }}
+
+ -
+
kill participation
+ {{ globalStats.kp|percent }}
+
+
+
+
+
Ranked Stats
+
Winrate
+
Record
+
+
+ -
+
{{ `${league.type} ${league.name.toLowerCase()}` }}
+ {{ calculateWinrate(league.wins, league.count).winrate|percent }}
+
+ {{ league.wins }}
+ -
+ {{ league.losses }}
+
+
+
+
+
+
+
Normal Stats
+
Winrate
+
Record
+
+
+ -
+
{{ `${league.type} ${league.name.toLowerCase()}` }}
+ {{ calculateWinrate(league.wins, league.count).winrate|percent }}
+
+ {{ league.wins }}
+ -
+ {{ league.losses }}
+
+
+
+
+
+
+
+
+
+
diff --git a/client/src/data/data.js b/client/src/data/data.js
index 61ecedf..b15c96a 100644
--- a/client/src/data/data.js
+++ b/client/src/data/data.js
@@ -1,3 +1,60 @@
export const maps = { 10: 'The Twisted Treeline', 11: "Summoner's Rift", 12: 'Howling Abyss' }
-export const gameModes = { 900: 'Ultra Rapide Fire', 450: 'ARAM', 400: 'DRAFT 5vs5', 420: 'Solo/Duo', 430: 'BLIND 5v5', 440: 'FLEX 5vs5', 460: 'BLIND 3vs3', 470: 'FLEX 3vs3', 800: '3v3 Co-op vs. AI (Intermediate)', 810: '3v3 Co-op vs. AI (Intro)', 820: '3v3 Co-op vs. AI (Beginner)', 830: 'Co-op vs. AI (Intro)', 840: 'Co-op vs. AI (Beginner)', 850: 'Co-op vs. AI (Intermediate)' }
+export const gameModes = {
+ 900: {
+ type: 'Normal',
+ name: 'URF',
+ },
+ 450: {
+ type: 'Normal',
+ name: 'ARAM',
+ },
+ 400: {
+ type: 'Normal',
+ name: 'DRAFT 5vs5',
+ },
+ 420: {
+ type: 'Ranked',
+ name: 'Solo/Duo',
+ },
+ 430: {
+ type: 'Normal',
+ name: 'BLIND 5v5',
+ },
+ 440: {
+ type: 'Ranked',
+ name: 'FLEX 5vs5',
+ },
+ 460: {
+ type: 'Normal',
+ name: 'BLIND 3vs3',
+ },
+ 470: {
+ type: 'Ranked',
+ name: 'FLEX 3vs3',
+ },
+ 800: {
+ type: 'Bot',
+ name: '3v3 Co-op vs. AI (Intermediate)',
+ },
+ 810: {
+ type: 'Bot',
+ name: '3v3 Co-op vs. AI (Intro)',
+ },
+ 820: {
+ type: 'Bot',
+ name: '3v3 Co-op vs. AI (Beginner)',
+ },
+ 830: {
+ type: 'Bot',
+ name: 'Co-op vs. AI (Intro)',
+ },
+ 840: {
+ type: 'Bot',
+ name: 'Co-op vs. AI (Beginner)',
+ },
+ 850: {
+ type: 'Bot',
+ name: 'Co-op vs. AI (Intermediate)',
+ }
+}
diff --git a/client/src/helpers/summoner.js b/client/src/helpers/summoner.js
index 1b9687d..19cdb09 100644
--- a/client/src/helpers/summoner.js
+++ b/client/src/helpers/summoner.js
@@ -100,7 +100,8 @@ export function createSummonerData(RiotData) {
matchList: RiotData.allMatches,
matches: createMatchData(RiotData.matchesDetails),
mates: createMatesData(RiotData.mates),
- playing: RiotData.playing
+ playing: RiotData.playing,
+ stats: RiotData.stats,
}
}
diff --git a/client/src/main.js b/client/src/main.js
index c2fc828..53b6892 100644
--- a/client/src/main.js
+++ b/client/src/main.js
@@ -10,6 +10,16 @@ import store from './store'
Vue.config.productionTip = false
Vue.use(VueAxios)
+Vue.filter('secToTime', (sec) => {
+ const min = Math.floor(sec / 60)
+ const newSec = sec - min * 60
+ return min + 'm' + (newSec < 10 ? '0' + newSec : newSec) + 's'
+})
+
+Vue.filter('percent', (value) => {
+ return `${+value.toFixed(2)}%`
+})
+
new Vue({
router,
store,
diff --git a/client/src/store/modules/summoner.js b/client/src/store/modules/summoner.js
index 9e4b25f..8860aa9 100644
--- a/client/src/store/modules/summoner.js
+++ b/client/src/store/modules/summoner.js
@@ -41,6 +41,7 @@ export const mutations = {
state.infos.matchIndex = infos.matches.length
state.infos.mates = infos.mates
state.infos.playing = infos.playing
+ state.infos.stats = infos.stats
state.status = 'found'
},
SUMMONER_NOT_FOUND(state) {
diff --git a/client/src/views/Summoner.vue b/client/src/views/Summoner.vue
index e9dfa71..5fec7e6 100644
--- a/client/src/views/Summoner.vue
+++ b/client/src/views/Summoner.vue
@@ -62,6 +62,7 @@
+
@@ -111,6 +112,7 @@ import SearchForm from '@/components/SearchForm.vue'
import SummonerLoader from '@/components/Summoner/SummonerLoader.vue'
import SummonerMates from '@/components/Summoner/SummonerMates.vue'
import SummonerRanked from '@/components/Summoner/SummonerRanked.vue'
+import SummonerStats from '@/components/Summoner/SummonerStats.vue'
export default {
components: {
@@ -123,6 +125,7 @@ export default {
SummonerLoader,
SummonerMates,
SummonerRanked,
+ SummonerStats,
},
computed: {
diff --git a/client/tailwind.config.js b/client/tailwind.config.js
index 1b7cecc..dd53b0c 100644
--- a/client/tailwind.config.js
+++ b/client/tailwind.config.js
@@ -90,6 +90,7 @@ module.exports = {
500: '#4299e1',
600: '#3182ce',
700: '#2b6cb0',
+ 760: '#2C5C94',
800: '#2c5282',
900: '#2a4365',
1000: '#17314f'
diff --git a/server/app/Controllers/Http/SummonerController.js b/server/app/Controllers/Http/SummonerController.js
index c942d2e..b08ffab 100644
--- a/server/app/Controllers/Http/SummonerController.js
+++ b/server/app/Controllers/Http/SummonerController.js
@@ -3,6 +3,7 @@
const Jax = use('Jax')
const MatchHelper = use('App/Helpers/MatchHelper')
const Summoner = use('App/Models/Summoner')
+const Match = use('App/Models/Match')
class SummonerController {
/**
@@ -62,6 +63,73 @@ class SummonerController {
// PATCH VERSION
finalJSON.version = Jax.DDragon.Version
+ // STATS
+ console.time('STATS')
+ const gamemodeStats = await Match.query().aggregate([
+ {
+ $match: {
+ summoner_puuid: account.puuid
+ }
+ },
+ {
+ $group: {
+ _id: "$gamemode",
+ count: { $sum: 1 },
+ wins: {
+ $sum: {
+ $cond: [
+ { $eq: ["$result", "Win"] }, 1, 0
+ ]
+ }
+ },
+ losses: {
+ $sum: {
+ $cond: [
+ { $eq: ["$result", "Fail"] }, 1, 0
+ ]
+ }
+ }
+ }
+ }
+ ])
+
+ const globalStats = await Match.query().aggregate([
+ {
+ $match: {
+ summoner_puuid: account.puuid
+ }
+ },
+ {
+ $group: {
+ _id: null,
+ count: { $sum: 1 },
+ time: { $sum: "$time" },
+ 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" },
+ minions: { $sum: "$stats.minions" },
+ vision: { $sum: "$stats.vision" },
+ kp: { $avg: "$stats.kp" },
+ }
+ }
+ ])
+ finalJSON.stats = [...globalStats, ...gamemodeStats]
+ console.timeEnd('STATS')
+
// SAVE IN DB
await summonerDB.save()
} catch (error) {
diff --git a/server/app/Transformers/MatchTransformer.js b/server/app/Transformers/MatchTransformer.js
index 6c63b4f..65cfb96 100644
--- a/server/app/Transformers/MatchTransformer.js
+++ b/server/app/Transformers/MatchTransformer.js
@@ -13,7 +13,8 @@ class MatchTransformer {
const map = this.match.mapId
const gamemode = this.match.queueId
const date = this.match.gameCreation
- const time = this.MatchHelper.secToTime(this.match.gameDuration)
+ // const time = this.MatchHelper.secToTime(this.match.gameDuration)
+ const time = this.match.gameDuration
return {
map,
@@ -76,7 +77,7 @@ class MatchTransformer {
return prev + current.stats.kills
}, 0)
- stats.kp = totalKills === 0 ? '0%' : +((stats.kills + stats.assists) * 100 / totalKills).toFixed(1) + '%'
+ stats.kp = totalKills === 0 ? 0 : +((stats.kills + stats.assists) * 100 / totalKills).toFixed(1)
}