diff --git a/server-v2/app/Models/Match.ts b/server-v2/app/Models/Match.ts new file mode 100644 index 0000000..de73667 --- /dev/null +++ b/server-v2/app/Models/Match.ts @@ -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 + + @hasOne(() => MatchTeam) + public redTeam: HasOne + + @hasMany(() => MatchPlayer) + public players: HasMany +} diff --git a/server-v2/app/Models/MatchPlayer.ts b/server-v2/app/Models/MatchPlayer.ts new file mode 100644 index 0000000..74b9c8d --- /dev/null +++ b/server-v2/app/Models/MatchPlayer.ts @@ -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 + + @column() + public participantId: number + + @column() + public summonerId: number + + @column() + public summonerPuuid: string + + @belongsTo(() => Summoner, { + localKey: 'puuid', + foreignKey: 'summonerPuuid', + }) + public summoner: BelongsTo + + @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[] +} diff --git a/server-v2/app/Models/MatchTeam.ts b/server-v2/app/Models/MatchTeam.ts new file mode 100644 index 0000000..d7bf296 --- /dev/null +++ b/server-v2/app/Models/MatchTeam.ts @@ -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 + + @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[] +} diff --git a/server-v2/app/Models/Summoner.ts b/server-v2/app/Models/Summoner.ts new file mode 100644 index 0000000..0ddb6a6 --- /dev/null +++ b/server-v2/app/Models/Summoner.ts @@ -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 + + @hasMany(() => MatchPlayer, { + localKey: 'puuid', + foreignKey: 'summonerPuuid', + }) + public matches: HasMany + + @hasMany(() => SummonerName, { + localKey: 'puuid', + foreignKey: 'summonerPuuid', + }) + public names: HasMany +} diff --git a/server-v2/app/Models/SummonerMatchlist.ts b/server-v2/app/Models/SummonerMatchlist.ts new file mode 100644 index 0000000..ed6ab10 --- /dev/null +++ b/server-v2/app/Models/SummonerMatchlist.ts @@ -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 +} diff --git a/server-v2/app/Models/SummonerName.ts b/server-v2/app/Models/SummonerName.ts new file mode 100644 index 0000000..ed22e9f --- /dev/null +++ b/server-v2/app/Models/SummonerName.ts @@ -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 + + @column() + public name: string + + @column.dateTime({ autoCreate: true }) + public createdAt: DateTime +} diff --git a/server-v2/database/migrations/1631392754960_matches.ts b/server-v2/database/migrations/1631392754960_matches.ts index 5bead9d..b843eb6 100644 --- a/server-v2/database/migrations/1631392754960_matches.ts +++ b/server-v2/database/migrations/1631392754960_matches.ts @@ -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() }) } diff --git a/server-v2/database/migrations/1631392766690_match_players.ts b/server-v2/database/migrations/1631392766690_match_players.ts index 65b660d..360ebd2 100644 --- a/server-v2/database/migrations/1631392766690_match_players.ts +++ b/server-v2/database/migrations/1631392766690_match_players.ts @@ -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() diff --git a/server-v2/database/migrations/1631397498477_match_teams.ts b/server-v2/database/migrations/1631397498477_match_teams.ts index 84b76a2..f098539 100644 --- a/server-v2/database/migrations/1631397498477_match_teams.ts +++ b/server-v2/database/migrations/1631397498477_match_teams.ts @@ -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()