mirror of
https://github.com/vkaelin/LeagueStats.git
synced 2026-03-25 12:57:28 +00:00
feat: add more stats in recent activity
This commit is contained in:
parent
239bcfb82e
commit
09621f100e
3 changed files with 36 additions and 5 deletions
|
|
@ -41,11 +41,25 @@
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<template #default>
|
<template #default>
|
||||||
<div class="px-2 text-xs text-center text-white">
|
<div class="px-2 text-xs text-center text-blue-200 leading-5">
|
||||||
<div>{{ day.date }}</div>
|
|
||||||
<div>
|
<div>
|
||||||
<span class="font-bold text-teal-400">{{ day.matches }}</span> game(s)
|
<span class="text-white font-semibold">{{ day.date }}</span>
|
||||||
|
<span>: </span>
|
||||||
|
<span class="font-bold text-teal-400">{{ day.matches }}</span>
|
||||||
|
<span> {{ day.matches > 1 ? 'games' : 'game' }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
<template v-if="day.matches > 0">
|
||||||
|
<div>
|
||||||
|
<span>time played: </span>
|
||||||
|
<span class="font-semibold text-white">{{ day.time|secToHours }}</span>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<span>record: </span>
|
||||||
|
<span class="font-bold text-green-400">{{ day.wins }}</span>
|
||||||
|
<span> - </span>
|
||||||
|
<span class="font-bold text-red-400">{{ day.losses }}</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|
@ -106,7 +120,10 @@ export default {
|
||||||
|
|
||||||
this.gridDays.push({
|
this.gridDays.push({
|
||||||
date: formattedDay,
|
date: formattedDay,
|
||||||
|
time: 0,
|
||||||
matches: 0,
|
matches: 0,
|
||||||
|
wins: 0,
|
||||||
|
losses: 0,
|
||||||
day: day.toLocaleString('en', { weekday: 'long' }).substring(0, 2),
|
day: day.toLocaleString('en', { weekday: 'long' }).substring(0, 2),
|
||||||
month: day.toLocaleString('en', { month: 'long' }).substring(0, 3)
|
month: day.toLocaleString('en', { month: 'long' }).substring(0, 3)
|
||||||
})
|
})
|
||||||
|
|
@ -124,7 +141,10 @@ export default {
|
||||||
e => e.date === formattedTime
|
e => e.date === formattedTime
|
||||||
)
|
)
|
||||||
if (dayOfTheMatch.length > 0) {
|
if (dayOfTheMatch.length > 0) {
|
||||||
dayOfTheMatch[0].matches = match.count
|
dayOfTheMatch[0].time = match.time
|
||||||
|
dayOfTheMatch[0].matches = match.wins + match.losses
|
||||||
|
dayOfTheMatch[0].wins = match.wins
|
||||||
|
dayOfTheMatch[0].losses = match.losses
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,15 @@ Vue.filter('secToTime', (sec, dotNotation = false) => {
|
||||||
return dotNotation ? `${min}:${newSec}` : `${min}m${newSec}s`
|
return dotNotation ? `${min}:${newSec}` : `${min}m${newSec}s`
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Vue.filter('secToHours', (sec) => {
|
||||||
|
if (isNaN(sec)) return 0
|
||||||
|
|
||||||
|
const h = Math.floor(sec / 3600)
|
||||||
|
const m = Math.floor((sec % 3600) / 60)
|
||||||
|
|
||||||
|
return h ? `${h}h ${m}m` : `${m}m`
|
||||||
|
})
|
||||||
|
|
||||||
Vue.filter('percent', (value) => {
|
Vue.filter('percent', (value) => {
|
||||||
return `${+value.toFixed(1)}%`
|
return `${+value.toFixed(1)}%`
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,9 @@ class MatchRepository {
|
||||||
const query = `
|
const query = `
|
||||||
SELECT
|
SELECT
|
||||||
to_timestamp(matches.date/1000)::date as day,
|
to_timestamp(matches.date/1000)::date as day,
|
||||||
COUNT(match_players.id) as count
|
SUM(matches.game_duration) as time,
|
||||||
|
COALESCE(SUM(match_players.win), 0) as wins,
|
||||||
|
COALESCE(SUM(match_players.loss), 0) as losses
|
||||||
FROM
|
FROM
|
||||||
match_players
|
match_players
|
||||||
${this.JOIN_MATCHES}
|
${this.JOIN_MATCHES}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue