mirror of
https://github.com/vkaelin/LeagueStats.git
synced 2026-03-25 12:57:28 +00:00
feat: add first version of Models
This commit is contained in:
parent
d82285050f
commit
753bda3418
9 changed files with 320 additions and 7 deletions
43
server-v2/app/Models/Match.ts
Normal file
43
server-v2/app/Models/Match.ts
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
import { BaseModel, column, HasMany, hasMany, HasOne, hasOne } from '@ioc:Adonis/Lucid/Orm'
|
||||
import MatchPlayer from './MatchPlayer'
|
||||
import MatchTeam from './MatchTeam'
|
||||
|
||||
export default class Match extends BaseModel {
|
||||
public static selfAssignPrimaryKey = true
|
||||
|
||||
@column({ isPrimary: true })
|
||||
public id: string
|
||||
|
||||
@column()
|
||||
public gameId: number
|
||||
|
||||
@column()
|
||||
public map: number
|
||||
|
||||
@column()
|
||||
public gamemode: number
|
||||
|
||||
@column()
|
||||
public date: number
|
||||
|
||||
@column()
|
||||
public region: string
|
||||
|
||||
@column()
|
||||
public result: number
|
||||
|
||||
@column()
|
||||
public season: number
|
||||
|
||||
@column()
|
||||
public gameDuration: number
|
||||
|
||||
@hasOne(() => MatchTeam)
|
||||
public blueTeam: HasOne<typeof MatchTeam>
|
||||
|
||||
@hasOne(() => MatchTeam)
|
||||
public redTeam: HasOne<typeof MatchTeam>
|
||||
|
||||
@hasMany(() => MatchPlayer)
|
||||
public players: HasMany<typeof MatchPlayer>
|
||||
}
|
||||
152
server-v2/app/Models/MatchPlayer.ts
Normal file
152
server-v2/app/Models/MatchPlayer.ts
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
import { BaseModel, BelongsTo, belongsTo, column } from '@ioc:Adonis/Lucid/Orm'
|
||||
import Match from './Match'
|
||||
import Summoner from './Summoner'
|
||||
|
||||
export default class MatchPlayer extends BaseModel {
|
||||
@column({ isPrimary: true })
|
||||
public id: number
|
||||
|
||||
@column()
|
||||
public matchId: number
|
||||
|
||||
@belongsTo(() => Match)
|
||||
public match: BelongsTo<typeof Match>
|
||||
|
||||
@column()
|
||||
public participantId: number
|
||||
|
||||
@column()
|
||||
public summonerId: number
|
||||
|
||||
@column()
|
||||
public summonerPuuid: string
|
||||
|
||||
@belongsTo(() => Summoner, {
|
||||
localKey: 'puuid',
|
||||
foreignKey: 'summonerPuuid',
|
||||
})
|
||||
public summoner: BelongsTo<typeof Summoner>
|
||||
|
||||
@column()
|
||||
public summonerName: string
|
||||
|
||||
@column()
|
||||
public team: number
|
||||
|
||||
@column()
|
||||
public teamPosition: string
|
||||
|
||||
@column()
|
||||
public kills: number
|
||||
|
||||
@column()
|
||||
public deaths: number
|
||||
|
||||
@column()
|
||||
public assists: number
|
||||
|
||||
@column()
|
||||
public kda: number
|
||||
|
||||
@column()
|
||||
public kp: number
|
||||
|
||||
@column()
|
||||
public champLevel: number
|
||||
|
||||
@column()
|
||||
public championId: number
|
||||
|
||||
@column()
|
||||
public championRole1: number
|
||||
|
||||
@column()
|
||||
public championRole2: number
|
||||
|
||||
@column()
|
||||
public doubleKills: number
|
||||
|
||||
@column()
|
||||
public tripleKills: number
|
||||
|
||||
@column()
|
||||
public quadraKills: number
|
||||
|
||||
@column()
|
||||
public pentaKills: number
|
||||
|
||||
@column()
|
||||
public baronKills: number
|
||||
|
||||
@column()
|
||||
public dragonKills: number
|
||||
|
||||
@column()
|
||||
public turretKills: number
|
||||
|
||||
@column()
|
||||
public visionScore: number
|
||||
|
||||
@column()
|
||||
public gold: number
|
||||
|
||||
@column()
|
||||
public summoner1Id: number
|
||||
|
||||
@column()
|
||||
public summoner2Id: number
|
||||
|
||||
@column()
|
||||
public item0: number
|
||||
|
||||
@column()
|
||||
public item1: number
|
||||
|
||||
@column()
|
||||
public item2: number
|
||||
|
||||
@column()
|
||||
public item3: number
|
||||
|
||||
@column()
|
||||
public item4: number
|
||||
|
||||
@column()
|
||||
public item5: number
|
||||
|
||||
@column()
|
||||
public item6: number
|
||||
|
||||
@column()
|
||||
public damageDealtObjectives: number
|
||||
|
||||
@column()
|
||||
public damageDealtChampions: number
|
||||
|
||||
@column()
|
||||
public damageTaken: number
|
||||
|
||||
@column()
|
||||
public heal: number
|
||||
|
||||
@column()
|
||||
public minions: number
|
||||
|
||||
@column()
|
||||
public criticalStrike: number
|
||||
|
||||
@column()
|
||||
public killingSpree: number
|
||||
|
||||
@column()
|
||||
public timeSpentLiving: number
|
||||
|
||||
@column()
|
||||
public perksPrimaryStyle: number
|
||||
|
||||
@column()
|
||||
public perksSecondaryStyle: number
|
||||
|
||||
@column()
|
||||
public perksSelected: number[]
|
||||
}
|
||||
37
server-v2/app/Models/MatchTeam.ts
Normal file
37
server-v2/app/Models/MatchTeam.ts
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import { BaseModel, BelongsTo, belongsTo, column } from '@ioc:Adonis/Lucid/Orm'
|
||||
import Match from './Match'
|
||||
|
||||
export default class MatchTeam extends BaseModel {
|
||||
@column({ isPrimary: true })
|
||||
public id: number
|
||||
|
||||
@column()
|
||||
public matchId: string
|
||||
|
||||
@belongsTo(() => Match)
|
||||
public match: BelongsTo<typeof Match>
|
||||
|
||||
@column()
|
||||
public color: string
|
||||
|
||||
@column()
|
||||
public result: number
|
||||
|
||||
@column()
|
||||
public barons: number
|
||||
|
||||
@column()
|
||||
public dragons: number
|
||||
|
||||
@column()
|
||||
public inhibitors: number
|
||||
|
||||
@column()
|
||||
public riftHeralds: number
|
||||
|
||||
@column()
|
||||
public bans: number[]
|
||||
|
||||
@column()
|
||||
public banOrders: number[]
|
||||
}
|
||||
36
server-v2/app/Models/Summoner.ts
Normal file
36
server-v2/app/Models/Summoner.ts
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import { DateTime } from 'luxon'
|
||||
import { BaseModel, column, HasMany, hasMany } from '@ioc:Adonis/Lucid/Orm'
|
||||
import SummonerMatchlist from './SummonerMatchlist'
|
||||
import SummonerName from './SummonerName'
|
||||
import MatchPlayer from './MatchPlayer'
|
||||
|
||||
export default class Summoner extends BaseModel {
|
||||
public static selfAssignPrimaryKey = true
|
||||
|
||||
@column({ isPrimary: true })
|
||||
public puuid: string
|
||||
|
||||
@column.dateTime({ autoCreate: true })
|
||||
public createdAt: DateTime
|
||||
|
||||
@column.dateTime({ autoCreate: true, autoUpdate: true })
|
||||
public updatedAt: DateTime
|
||||
|
||||
@hasMany(() => SummonerMatchlist, {
|
||||
localKey: 'puuid',
|
||||
foreignKey: 'summonerPuuid',
|
||||
})
|
||||
public matchlist: HasMany<typeof SummonerMatchlist>
|
||||
|
||||
@hasMany(() => MatchPlayer, {
|
||||
localKey: 'puuid',
|
||||
foreignKey: 'summonerPuuid',
|
||||
})
|
||||
public matches: HasMany<typeof MatchPlayer>
|
||||
|
||||
@hasMany(() => SummonerName, {
|
||||
localKey: 'puuid',
|
||||
foreignKey: 'summonerPuuid',
|
||||
})
|
||||
public names: HasMany<typeof SummonerName>
|
||||
}
|
||||
19
server-v2/app/Models/SummonerMatchlist.ts
Normal file
19
server-v2/app/Models/SummonerMatchlist.ts
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import { BaseModel, BelongsTo, belongsTo, column } from '@ioc:Adonis/Lucid/Orm'
|
||||
import Summoner from './Summoner'
|
||||
|
||||
export default class SummonerMatchlist extends BaseModel {
|
||||
@column({ isPrimary: true })
|
||||
public id: number
|
||||
|
||||
@column()
|
||||
public summonerPuuid: string
|
||||
|
||||
@column()
|
||||
public matchId: string
|
||||
|
||||
@belongsTo(() => Summoner, {
|
||||
localKey: 'puuid',
|
||||
foreignKey: 'summonerPuuid',
|
||||
})
|
||||
public summoner: BelongsTo<typeof Summoner>
|
||||
}
|
||||
23
server-v2/app/Models/SummonerName.ts
Normal file
23
server-v2/app/Models/SummonerName.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import { DateTime } from 'luxon'
|
||||
import { BaseModel, BelongsTo, belongsTo, column } from '@ioc:Adonis/Lucid/Orm'
|
||||
import Summoner from './Summoner'
|
||||
|
||||
export default class SummonerName extends BaseModel {
|
||||
@column({ isPrimary: true })
|
||||
public id: number
|
||||
|
||||
@column()
|
||||
public summonerPuuid: string
|
||||
|
||||
@belongsTo(() => Summoner, {
|
||||
localKey: 'puuid',
|
||||
foreignKey: 'summonerPuuid',
|
||||
})
|
||||
public summoner: BelongsTo<typeof Summoner>
|
||||
|
||||
@column()
|
||||
public name: string
|
||||
|
||||
@column.dateTime({ autoCreate: true })
|
||||
public createdAt: DateTime
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@ export default class Matches extends BaseSchema {
|
|||
public async up() {
|
||||
this.schema.createTable(this.tableName, (table) => {
|
||||
table.string('id', 15).primary()
|
||||
table.integer('gameId').notNullable()
|
||||
table.integer('game_id').notNullable()
|
||||
table.integer('map').notNullable()
|
||||
table.integer('gamemode').notNullable()
|
||||
table.integer('date').notNullable()
|
||||
|
|
@ -16,8 +16,8 @@ export default class Matches extends BaseSchema {
|
|||
table.integer('season').notNullable()
|
||||
table.integer('game_duration').notNullable()
|
||||
|
||||
table.integer('blue_team_id').notNullable()
|
||||
table.integer('red_team_id').notNullable()
|
||||
// table.integer('blue_team_id').notNullable()
|
||||
// table.integer('red_team_id').notNullable()
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@ export default class MatchPlayers extends BaseSchema {
|
|||
table.integer('kills').notNullable()
|
||||
table.integer('deaths').notNullable()
|
||||
table.integer('assists').notNullable()
|
||||
table.integer('kda').notNullable()
|
||||
table.float('kda').notNullable()
|
||||
table.float('kp').notNullable()
|
||||
|
||||
table.integer('champ_level').notNullable()
|
||||
table.integer('champion_id').notNullable()
|
||||
|
|
@ -49,7 +50,7 @@ export default class MatchPlayers extends BaseSchema {
|
|||
table.integer('item6').notNullable()
|
||||
|
||||
table.integer('damage_dealt_objectives').notNullable()
|
||||
table.integer('damage_dealt_to_champions').notNullable()
|
||||
table.integer('damage_dealt_champions').notNullable()
|
||||
table.integer('damage_taken').notNullable()
|
||||
table.integer('heal').notNullable()
|
||||
table.integer('minions').notNullable()
|
||||
|
|
|
|||
|
|
@ -6,12 +6,14 @@ export default class MatchTeams extends BaseSchema {
|
|||
public async up() {
|
||||
this.schema.createTable(this.tableName, (table) => {
|
||||
table.increments('id')
|
||||
table.string('match_id', 15)
|
||||
|
||||
table.string('color', 4).notNullable()
|
||||
table.integer('result').notNullable()
|
||||
|
||||
table.integer('barons').notNullable()
|
||||
table.string('color', 4).notNullable()
|
||||
table.integer('dragons').notNullable()
|
||||
table.integer('inhibitors').notNullable()
|
||||
table.integer('result').notNullable()
|
||||
table.integer('rift_heralds').notNullable()
|
||||
|
||||
table.specificType('bans', 'INT[]').notNullable()
|
||||
|
|
|
|||
Loading…
Reference in a new issue