mirror of
https://github.com/vkaelin/LeagueStats.git
synced 2026-03-25 12:57:28 +00:00
feat: add back records tab
This commit is contained in:
parent
75b1007ec0
commit
ed79b4cd7c
5 changed files with 57 additions and 75 deletions
|
|
@ -5,7 +5,7 @@
|
||||||
:style="{
|
:style="{
|
||||||
backgroundImage:
|
backgroundImage:
|
||||||
`${hover ? gradientHover : gradient},
|
`${hover ? gradientHover : gradient},
|
||||||
url('https://raw.communitydragon.org/latest/plugins/rcp-be-lol-game-data/global/default/v1/champion-splashes/${record.champion.id}/${record.champion.id}000.jpg')`
|
url('https://raw.communitydragon.org/latest/plugins/rcp-be-lol-game-data/global/default/v1/champion-splashes/${record.champion_id}/${record.champion_id}000.jpg')`
|
||||||
}"
|
}"
|
||||||
:class="borderColor"
|
:class="borderColor"
|
||||||
class="relative w-full p-4 mx-2 mt-6 leading-none bg-center bg-cover border rounded-lg record-card"
|
class="relative w-full p-4 mx-2 mt-6 leading-none bg-center bg-cover border rounded-lg record-card"
|
||||||
|
|
@ -21,18 +21,18 @@
|
||||||
<span :class="textColor" class="ml-0">{{ title }}</span>
|
<span :class="textColor" class="ml-0">{{ title }}</span>
|
||||||
</div>
|
</div>
|
||||||
<img
|
<img
|
||||||
:src="`https://raw.communitydragon.org/latest/plugins/rcp-be-lol-game-data/global/default/v1/champion-icons/${record.champion.id}.png`"
|
:src="`https://raw.communitydragon.org/latest/plugins/rcp-be-lol-game-data/global/default/v1/champion-icons/${record.champion_id}.png`"
|
||||||
:class="[{'opacity-0 scale-125': hover}, borderColor]"
|
:class="[{'opacity-0 scale-125': hover}, borderColor]"
|
||||||
class="block w-16 h-16 mx-auto mt-10 transition duration-500 ease-in transform border-2 rounded-full"
|
class="block w-16 h-16 mx-auto mt-10 transition duration-500 ease-in transform border-2 rounded-full"
|
||||||
alt="Champion Played"
|
alt="Champion Played"
|
||||||
/>
|
/>
|
||||||
<div :style="{textShadow: `-2px 1px 6px ${color}`}" class="mt-6 text-4xl">{{ record[property] }}</div>
|
<div :style="{textShadow: `-2px 1px 6px ${color}`}" class="mt-6 text-4xl">{{ record.amount }}</div>
|
||||||
|
|
||||||
<div class="text-sm">
|
<div class="text-sm">
|
||||||
<div class="mt-6">
|
<div class="mt-6">
|
||||||
<span
|
<span
|
||||||
:class="record.result === 'Win' ? 'text-green-400' : 'text-red-400'"
|
:class="record.result ? 'text-green-400' : 'text-red-400'"
|
||||||
>{{ record.result === 'Win' ? 'Won' : 'Lost' }}</span>
|
>{{ record.result ? 'Won' : 'Lost' }}</span>
|
||||||
<span class="ml-1 font-semibold">{{ timeDifference(record.date) }}</span>
|
<span class="ml-1 font-semibold">{{ timeDifference(record.date) }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-2 text-gray-500">
|
<div class="mt-2 text-gray-500">
|
||||||
|
|
@ -41,7 +41,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-6 text-xs font-light text-right text-gray-200 opacity-25">
|
<div class="mt-6 text-xs font-light text-right text-gray-200 opacity-25">
|
||||||
<span v-if="hover">match {{ record.gameId }}</span>
|
<span v-if="hover">{{ record.id }}</span>
|
||||||
<span v-else>{{ gameModes[record.gamemode].name }}</span>
|
<span v-else>{{ gameModes[record.gamemode].name }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -65,10 +65,6 @@ export default {
|
||||||
type: String,
|
type: String,
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
property: {
|
|
||||||
type: String,
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
record: {
|
record: {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true
|
required: true
|
||||||
|
|
|
||||||
|
|
@ -66,21 +66,22 @@ export function createBasicSummonerData(RiotData) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the formatted records of a summoner
|
* Return the formatted records of a summoner
|
||||||
* @param {Object} records : raw records from the database stats
|
* @param {Object} recordsDto : raw records from the database stats
|
||||||
*/
|
*/
|
||||||
export function createRecordsData(records) {
|
export function createRecordsData(recordsDto) {
|
||||||
records.maxTime.time = secToTime(records.maxTime.time)
|
const records = recordsDto.reduce((acc, record) => {
|
||||||
records.maxGold.gold = records.maxGold.gold.toLocaleString()
|
acc[record.what] = record
|
||||||
records.maxDmgTaken.dmgTaken = records.maxDmgTaken.dmgTaken.toLocaleString()
|
return acc
|
||||||
records.maxDmgChamp.dmgChamp = records.maxDmgChamp.dmgChamp.toLocaleString()
|
}, {})
|
||||||
records.maxDmgObj.dmgObj = records.maxDmgObj.dmgObj.toLocaleString()
|
|
||||||
records.maxKp.kp = `${records.maxKp.kp}%`
|
|
||||||
|
|
||||||
// New record fields
|
records.game_duration.amount = secToTime(records.game_duration.amount)
|
||||||
if (records.maxLiving) {
|
records.gold.amount = records.gold.amount.toLocaleString()
|
||||||
records.maxLiving.longestLiving = secToTime(records.maxLiving.longestLiving)
|
records.damage_taken.amount = records.damage_taken.amount.toLocaleString()
|
||||||
records.maxHeal.heal = records.maxHeal.heal.toLocaleString()
|
records.damage_dealt_champions.amount = records.damage_dealt_champions.amount.toLocaleString()
|
||||||
}
|
records.damage_dealt_objectives.amount = records.damage_dealt_objectives.amount.toLocaleString()
|
||||||
|
records.kp.amount = `${records.kp.amount}%`
|
||||||
|
records.time_spent_living.amount = secToTime(records.time_spent_living.amount)
|
||||||
|
records.heal.amount = records.heal.amount.toLocaleString()
|
||||||
|
|
||||||
return records
|
return records
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ export const state = {
|
||||||
championsLoaded: false
|
championsLoaded: false
|
||||||
},
|
},
|
||||||
records: {
|
records: {
|
||||||
list: [],
|
list: {},
|
||||||
recordsLoaded: false
|
recordsLoaded: false
|
||||||
},
|
},
|
||||||
live: {
|
live: {
|
||||||
|
|
@ -81,6 +81,7 @@ export const mutations = {
|
||||||
state.overview.matchIndex = infos.matches.length
|
state.overview.matchIndex = infos.matches.length
|
||||||
state.overview.stats = infos.stats
|
state.overview.stats = infos.stats
|
||||||
state.overview.loaded = true
|
state.overview.loaded = true
|
||||||
|
state.records.recordsLoaded = false
|
||||||
},
|
},
|
||||||
RECORDS_FOUND(state, { records }) {
|
RECORDS_FOUND(state, { records }) {
|
||||||
state.records.list = records
|
state.records.list = records
|
||||||
|
|
@ -218,7 +219,7 @@ export const actions = {
|
||||||
const resp = await axios(({ url: 'summoner/records', data: { puuid: state.basic.account.puuid }, method: 'POST' })).catch(() => { })
|
const resp = await axios(({ url: 'summoner/records', data: { puuid: state.basic.account.puuid }, method: 'POST' })).catch(() => { })
|
||||||
console.log('---RECORDS---')
|
console.log('---RECORDS---')
|
||||||
console.log(resp.data)
|
console.log(resp.data)
|
||||||
const records = resp.data ? createRecordsData(resp.data) : {}
|
const records = resp.data.length ? createRecordsData(resp.data) : {}
|
||||||
|
|
||||||
commit('RECORDS_FOUND', { records })
|
commit('RECORDS_FOUND', { records })
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div key="records">
|
<div key="records">
|
||||||
<template v-if="!recordsLoaded || (recordsLoaded && records.maxKda)">
|
<template v-if="!recordsLoaded || (recordsLoaded && records.assists)">
|
||||||
<div
|
<div
|
||||||
class="relative pl-6 text-2xl text-blue-200 border-b-2 border-blue-800 category blue-900"
|
class="relative pl-6 text-2xl text-blue-200 border-b-2 border-blue-800 category blue-900"
|
||||||
>Basics</div>
|
>Basics</div>
|
||||||
|
|
@ -10,48 +10,42 @@
|
||||||
color="#63b3ed"
|
color="#63b3ed"
|
||||||
text-color="text-blue-400"
|
text-color="text-blue-400"
|
||||||
border-color="border-blue-400"
|
border-color="border-blue-400"
|
||||||
property="kda"
|
:record="records.kda"
|
||||||
:record="records.maxKda"
|
|
||||||
title="KDA"
|
title="KDA"
|
||||||
/>
|
/>
|
||||||
<RecordCard
|
<RecordCard
|
||||||
color="#68D391"
|
color="#68D391"
|
||||||
text-color="text-green-400"
|
text-color="text-green-400"
|
||||||
border-color="border-green-400"
|
border-color="border-green-400"
|
||||||
property="kills"
|
:record="records.kills"
|
||||||
:record="records.maxKills"
|
|
||||||
title="Kills"
|
title="Kills"
|
||||||
/>
|
/>
|
||||||
<RecordCard
|
<RecordCard
|
||||||
color="#9F7AEA"
|
color="#9F7AEA"
|
||||||
text-color="text-purple-500"
|
text-color="text-purple-500"
|
||||||
border-color="border-purple-500"
|
border-color="border-purple-500"
|
||||||
property="assists"
|
:record="records.assists"
|
||||||
:record="records.maxAssists"
|
|
||||||
title="Assists"
|
title="Assists"
|
||||||
/>
|
/>
|
||||||
<RecordCard
|
<RecordCard
|
||||||
color="#F56565"
|
color="#F56565"
|
||||||
text-color="text-red-500"
|
text-color="text-red-500"
|
||||||
border-color="border-red-500"
|
border-color="border-red-500"
|
||||||
property="deaths"
|
:record="records.deaths"
|
||||||
:record="records.maxDeaths"
|
|
||||||
title="Deaths"
|
title="Deaths"
|
||||||
/>
|
/>
|
||||||
<RecordCard
|
<RecordCard
|
||||||
color="#D69E2E"
|
color="#D69E2E"
|
||||||
text-color="text-yellow-600"
|
text-color="text-yellow-600"
|
||||||
border-color="border-yellow-600"
|
border-color="border-yellow-600"
|
||||||
property="gold"
|
:record="records.gold"
|
||||||
:record="records.maxGold"
|
|
||||||
title="Gold earned"
|
title="Gold earned"
|
||||||
/>
|
/>
|
||||||
<RecordCard
|
<RecordCard
|
||||||
color="#81E6D9"
|
color="#81E6D9"
|
||||||
text-color="text-teal-300"
|
text-color="text-teal-300"
|
||||||
border-color="border-teal-300"
|
border-color="border-teal-300"
|
||||||
property="minions"
|
:record="records.minions"
|
||||||
:record="records.maxMinions"
|
|
||||||
title="Minions killed"
|
title="Minions killed"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -81,24 +75,21 @@
|
||||||
color="#FC8181"
|
color="#FC8181"
|
||||||
text-color="text-red-400"
|
text-color="text-red-400"
|
||||||
border-color="border-red-400"
|
border-color="border-red-400"
|
||||||
property="dmgChamp"
|
:record="records.damage_dealt_champions"
|
||||||
:record="records.maxDmgChamp"
|
|
||||||
title="Damage champions"
|
title="Damage champions"
|
||||||
/>
|
/>
|
||||||
<RecordCard
|
<RecordCard
|
||||||
color="#D69E2E"
|
color="#D69E2E"
|
||||||
text-color="text-yellow-400"
|
text-color="text-yellow-400"
|
||||||
border-color="border-yellow-400"
|
border-color="border-yellow-400"
|
||||||
property="dmgObj"
|
:record="records.damage_dealt_objectives"
|
||||||
:record="records.maxDmgObj"
|
|
||||||
title="Damage objectives"
|
title="Damage objectives"
|
||||||
/>
|
/>
|
||||||
<RecordCard
|
<RecordCard
|
||||||
color="#FC8181"
|
color="#FC8181"
|
||||||
text-color="text-red-400"
|
text-color="text-red-400"
|
||||||
border-color="border-red-400"
|
border-color="border-red-400"
|
||||||
property="dmgTaken"
|
:record="records.damage_taken"
|
||||||
:record="records.maxDmgTaken"
|
|
||||||
title="Damage taken"
|
title="Damage taken"
|
||||||
/>
|
/>
|
||||||
<RecordCard
|
<RecordCard
|
||||||
|
|
@ -106,24 +97,21 @@
|
||||||
color="#D69E2E"
|
color="#D69E2E"
|
||||||
text-color="text-yellow-400"
|
text-color="text-yellow-400"
|
||||||
border-color="border-yellow-400"
|
border-color="border-yellow-400"
|
||||||
property="towers"
|
:record="records.turret_kills"
|
||||||
:record="records.maxTowers"
|
|
||||||
title="Towers"
|
title="Towers"
|
||||||
/>
|
/>
|
||||||
<RecordCard
|
<RecordCard
|
||||||
color="#68D391"
|
color="#68D391"
|
||||||
text-color="text-green-400"
|
text-color="text-green-400"
|
||||||
border-color="border-green-400"
|
border-color="border-green-400"
|
||||||
property="kp"
|
:record="records.kp"
|
||||||
:record="records.maxKp"
|
|
||||||
title="Kill participation"
|
title="Kill participation"
|
||||||
/>
|
/>
|
||||||
<RecordCard
|
<RecordCard
|
||||||
color="#D69E2E"
|
color="#D69E2E"
|
||||||
text-color="text-yellow-400"
|
text-color="text-yellow-400"
|
||||||
border-color="border-yellow-400"
|
border-color="border-yellow-400"
|
||||||
property="vision"
|
:record="records.vision_score"
|
||||||
:record="records.maxVision"
|
|
||||||
title="Vision score"
|
title="Vision score"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -153,35 +141,28 @@
|
||||||
color="#4299E1"
|
color="#4299E1"
|
||||||
text-color="text-blue-500"
|
text-color="text-blue-500"
|
||||||
border-color="border-blue-500"
|
border-color="border-blue-500"
|
||||||
property="time"
|
:record="records.game_duration"
|
||||||
:record="records.maxTime"
|
|
||||||
title="Longest game"
|
title="Longest game"
|
||||||
/>
|
/>
|
||||||
<RecordCard
|
<RecordCard
|
||||||
v-if="records.maxLiving"
|
|
||||||
color="#4299E1"
|
color="#4299E1"
|
||||||
text-color="text-blue-500"
|
text-color="text-blue-500"
|
||||||
border-color="border-blue-500"
|
border-color="border-blue-500"
|
||||||
property="longestLiving"
|
:record="records.time_spent_living"
|
||||||
:record="records.maxLiving"
|
|
||||||
title="Longest living"
|
title="Longest living"
|
||||||
/>
|
/>
|
||||||
<RecordCard
|
<RecordCard
|
||||||
v-if="records.maxCriticalStrike"
|
|
||||||
color="#D69E2E"
|
color="#D69E2E"
|
||||||
text-color="text-yellow-400"
|
text-color="text-yellow-400"
|
||||||
border-color="border-yellow-400"
|
border-color="border-yellow-400"
|
||||||
property="criticalStrike"
|
:record="records.critical_strike"
|
||||||
:record="records.maxCriticalStrike"
|
|
||||||
title="Critical Strike"
|
title="Critical Strike"
|
||||||
/>
|
/>
|
||||||
<RecordCard
|
<RecordCard
|
||||||
v-if="records.maxHeal"
|
|
||||||
color="#68D391"
|
color="#68D391"
|
||||||
text-color="text-green-400"
|
text-color="text-green-400"
|
||||||
border-color="border-green-400"
|
border-color="border-green-400"
|
||||||
property="heal"
|
:record="records.heal"
|
||||||
:record="records.maxHeal"
|
|
||||||
title="Heal"
|
title="Heal"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -204,47 +185,42 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="records.maxDouble" class="relative pl-6 mt-3 text-2xl text-blue-200 border-b-2 border-blue-800 category">Multi kills</div>
|
<div class="relative pl-6 mt-3 text-2xl text-blue-200 border-b-2 border-blue-800 category">Multi kills</div>
|
||||||
<div v-if="records.maxDouble" class="flex flex-wrap -mx-2">
|
<div class="flex flex-wrap -mx-2">
|
||||||
<template v-if="recordsLoaded">
|
<template v-if="recordsLoaded">
|
||||||
<RecordCard
|
<RecordCard
|
||||||
color="#FEFCBF"
|
color="#FEFCBF"
|
||||||
text-color="text-yellow-200"
|
text-color="text-yellow-200"
|
||||||
border-color="border-yellow-200"
|
border-color="border-yellow-200"
|
||||||
property="doubleKills"
|
:record="records.double_kills"
|
||||||
:record="records.maxDouble"
|
|
||||||
title="Double kills"
|
title="Double kills"
|
||||||
/>
|
/>
|
||||||
<RecordCard
|
<RecordCard
|
||||||
color="#F6E05E"
|
color="#F6E05E"
|
||||||
text-color="text-yellow-400"
|
text-color="text-yellow-400"
|
||||||
border-color="border-yellow-400"
|
border-color="border-yellow-400"
|
||||||
property="tripleKills"
|
:record="records.triple_kills"
|
||||||
:record="records.maxTriple"
|
|
||||||
title="Triple kills"
|
title="Triple kills"
|
||||||
/>
|
/>
|
||||||
<RecordCard
|
<RecordCard
|
||||||
color="#D69E2E"
|
color="#D69E2E"
|
||||||
text-color="text-yellow-600"
|
text-color="text-yellow-600"
|
||||||
border-color="border-yellow-600"
|
border-color="border-yellow-600"
|
||||||
property="quadraKills"
|
:record="records.quadra_kills"
|
||||||
:record="records.maxQuadra"
|
|
||||||
title="Quadra kills"
|
title="Quadra kills"
|
||||||
/>
|
/>
|
||||||
<RecordCard
|
<RecordCard
|
||||||
color="#F56565"
|
color="#F56565"
|
||||||
text-color="text-red-500"
|
text-color="text-red-500"
|
||||||
border-color="border-red-500"
|
border-color="border-red-500"
|
||||||
property="pentaKills"
|
:record="records.penta_kills"
|
||||||
:record="records.maxPenta"
|
|
||||||
title="Penta kills"
|
title="Penta kills"
|
||||||
/>
|
/>
|
||||||
<RecordCard
|
<RecordCard
|
||||||
color="#63b3ed"
|
color="#63b3ed"
|
||||||
text-color="text-blue-400"
|
text-color="text-blue-400"
|
||||||
border-color="border-blue-400"
|
border-color="border-blue-400"
|
||||||
property="killingSpree"
|
:record="records.killing_spree"
|
||||||
:record="records.maxKillingSpree"
|
|
||||||
title="Killing Spree"
|
title="Killing Spree"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -268,7 +244,7 @@
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template v-if="recordsLoaded && !records.maxKda">
|
<template v-if="recordsLoaded && !records.assists">
|
||||||
<div class="flex flex-col items-center mt-4">
|
<div class="flex flex-col items-center mt-4">
|
||||||
<div>No records have been found.</div>
|
<div>No records have been found.</div>
|
||||||
<div>😕</div>
|
<div>😕</div>
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
import { getCurrentSeason } from 'App/helpers'
|
import { getCurrentSeason } from 'App/helpers'
|
||||||
import Summoner from 'App/Models/Summoner'
|
import Summoner from 'App/Models/Summoner'
|
||||||
import MatchRepository from 'App/Repositories/MatchRepository'
|
import MatchRepository from 'App/Repositories/MatchRepository'
|
||||||
|
import BasicMatchSerializer from 'App/Serializers/BasicMatchSerializer'
|
||||||
import Jax from 'App/Services/Jax'
|
import Jax from 'App/Services/Jax'
|
||||||
import MatchService from 'App/Services/MatchService'
|
import MatchService from 'App/Services/MatchService'
|
||||||
import StatsService from 'App/Services/StatsService'
|
import StatsService from 'App/Services/StatsService'
|
||||||
|
|
@ -94,7 +95,14 @@ export default class SummonersController {
|
||||||
console.time('recordsRequest')
|
console.time('recordsRequest')
|
||||||
const { puuid, season } = await request.validate(SummonerRecordValidator)
|
const { puuid, season } = await request.validate(SummonerRecordValidator)
|
||||||
const records = await MatchRepository.records(puuid)
|
const records = await MatchRepository.records(puuid)
|
||||||
|
const recordsSerialized = records.map((record) => {
|
||||||
|
return {
|
||||||
|
...record,
|
||||||
|
what: record.what.split('.')[1],
|
||||||
|
champion: BasicMatchSerializer.getChampion(record.champion_id),
|
||||||
|
}
|
||||||
|
})
|
||||||
console.timeEnd('recordsRequest')
|
console.timeEnd('recordsRequest')
|
||||||
return response.json(records)
|
return response.json(recordsSerialized)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue