mirror of
https://github.com/vkaelin/LeagueStats.git
synced 2026-03-25 12:57:28 +00:00
feat: parsing matchPlayers + change in model/migration
This commit is contained in:
parent
45750d64eb
commit
49f16c287b
3 changed files with 56 additions and 3 deletions
|
|
@ -16,7 +16,7 @@ export default class MatchPlayer extends BaseModel {
|
||||||
public participantId: number
|
public participantId: number
|
||||||
|
|
||||||
@column()
|
@column()
|
||||||
public summonerId: number
|
public summonerId: string
|
||||||
|
|
||||||
@column()
|
@column()
|
||||||
public summonerPuuid: string
|
public summonerPuuid: string
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import { MatchDto } from 'App/Services/Jax/src/Endpoints/MatchEndpoint'
|
import { MatchDto } from 'App/Services/Jax/src/Endpoints/MatchEndpoint'
|
||||||
import Match from 'App/Models/Match'
|
import Match from 'App/Models/Match'
|
||||||
|
import MatchPlayer from 'App/Models/MatchPlayer'
|
||||||
import { getSeasonNumber } from 'App/helpers'
|
import { getSeasonNumber } from 'App/helpers'
|
||||||
class MatchParser {
|
class MatchParser {
|
||||||
public async parseOneMatch(match: MatchDto) {
|
public async parseOneMatch(match: MatchDto) {
|
||||||
|
|
@ -21,7 +22,7 @@ class MatchParser {
|
||||||
|
|
||||||
// - 2x MatchTeam : Red and Blue
|
// - 2x MatchTeam : Red and Blue
|
||||||
let result = 'Remake'
|
let result = 'Remake'
|
||||||
for (let team of match.info.teams) {
|
for (const team of match.info.teams) {
|
||||||
if (match.info.gameDuration >= 300) {
|
if (match.info.gameDuration >= 300) {
|
||||||
result = team.win ? 'Win' : 'Fail'
|
result = team.win ? 'Win' : 'Fail'
|
||||||
}
|
}
|
||||||
|
|
@ -41,6 +42,58 @@ class MatchParser {
|
||||||
|
|
||||||
// - 10x MatchPlayer // TODO
|
// - 10x MatchPlayer // TODO
|
||||||
|
|
||||||
|
const matchPlayers = match.info.participants.map(
|
||||||
|
(p) => <MatchPlayer>(<unknown>{
|
||||||
|
matchId: match.metadata.matchId,
|
||||||
|
participantId: p.participantId,
|
||||||
|
summonerId: p.summonerId,
|
||||||
|
summonerPuuid: p.puuid,
|
||||||
|
summonerName: p.summonerName,
|
||||||
|
team: p.teamId,
|
||||||
|
teamPosition: p.teamPosition,
|
||||||
|
kills: p.kills,
|
||||||
|
deaths: p.deaths,
|
||||||
|
assists: p.assists,
|
||||||
|
kda: 100,
|
||||||
|
kp: 100,
|
||||||
|
champLevel: p.champLevel,
|
||||||
|
championId: p.championId,
|
||||||
|
championRole1: 1,
|
||||||
|
championRole2: 2,
|
||||||
|
doubleKills: p.doubleKills,
|
||||||
|
tripleKills: p.tripleKills,
|
||||||
|
quadraKills: p.quadraKills,
|
||||||
|
pentaKills: p.pentaKills,
|
||||||
|
baronKills: p.baronKills,
|
||||||
|
dragonKills: p.dragonKills,
|
||||||
|
turretKills: p.turretKills,
|
||||||
|
visionScore: p.visionScore,
|
||||||
|
gold: p.goldEarned,
|
||||||
|
summoner1Id: p.summoner1Id,
|
||||||
|
summoner2Id: p.summoner2Id,
|
||||||
|
item0: p.item0,
|
||||||
|
item1: p.item1,
|
||||||
|
item2: p.item2,
|
||||||
|
item3: p.item3,
|
||||||
|
item4: p.item4,
|
||||||
|
item5: p.item5,
|
||||||
|
item6: p.item6,
|
||||||
|
damageDealtObjectives: p.damageDealtToObjectives,
|
||||||
|
damageDealtChampions: p.totalDamageDealtToChampions,
|
||||||
|
damageTaken: p.totalDamageTaken,
|
||||||
|
heal: p.totalHeal,
|
||||||
|
minions: p.totalMinionsKilled,
|
||||||
|
criticalStrike: p.largestCriticalStrike,
|
||||||
|
killingSpree: p.killingSprees,
|
||||||
|
timeSpentLiving: p.longestTimeSpentLiving,
|
||||||
|
perksPrimaryStyle: 100,
|
||||||
|
perksSecondaryStyle: 100,
|
||||||
|
perksSelected: [1, 2, 3],
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
parsedMatch.related('players').createMany(matchPlayers)
|
||||||
|
|
||||||
return parsedMatch
|
return parsedMatch
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ export default class MatchPlayers extends BaseSchema {
|
||||||
table.string('match_id', 15).notNullable()
|
table.string('match_id', 15).notNullable()
|
||||||
|
|
||||||
table.integer('participant_id').notNullable()
|
table.integer('participant_id').notNullable()
|
||||||
table.integer('summoner_id').notNullable()
|
table.string('summoner_id', 78).notNullable() // check length
|
||||||
table.string('summoner_puuid', 78).notNullable()
|
table.string('summoner_puuid', 78).notNullable()
|
||||||
table.string('summoner_name', 16).notNullable()
|
table.string('summoner_name', 16).notNullable()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue