From cfb913bfb9d812b5b622faf44ce100a14429149a Mon Sep 17 00:00:00 2001 From: legonzaur Date: Thu, 20 Apr 2023 12:27:26 +0200 Subject: [PATCH 01/22] add gamemodes route --- src/client/client.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/client/client.ts b/src/client/client.ts index 4e0f291..512dad5 100644 --- a/src/client/client.ts +++ b/src/client/client.ts @@ -33,7 +33,7 @@ router.get( '/:dataType', param('dataType') .custom( - (e) => e == 'weapons' || e == 'players' || e == 'maps' || e == 'servers' + (e) => e == 'weapons' || e == 'players' || e == 'maps' || e == 'servers' || e == 'gamemodes' ) .withMessage('Only weapons, players, maps or servers are valid paths'), query(['player', 'host']).optional().toInt().isInt(), @@ -50,7 +50,7 @@ router.get( host?: number } } = {} - let index: 'cause_of_death' | 'attacker_id' | 'map' | 'servername' + let index: 'cause_of_death' | 'attacker_id' | 'map' | 'servername' | 'game_mode' switch (req.params.dataType) { case 'weapons': index = 'cause_of_death' @@ -64,6 +64,9 @@ router.get( case 'servers': index = 'servername' break + case 'gamemodes': + index = 'game_mode' + break default: return res.status(400).send() } From fb309530351bad69e81a8900cee55f0b76e24243 Mon Sep 17 00:00:00 2001 From: legonzaur Date: Thu, 20 Apr 2023 14:29:57 +0200 Subject: [PATCH 02/22] add titan support --- .../migrations/2023-04-20-01 Titan support.ts | 31 +++++++++++++++++++ src/db/model.ts | 1 + src/server/server.ts | 4 ++- 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 src/db/migrations/2023-04-20-01 Titan support.ts diff --git a/src/db/migrations/2023-04-20-01 Titan support.ts b/src/db/migrations/2023-04-20-01 Titan support.ts new file mode 100644 index 0000000..4c12f0d --- /dev/null +++ b/src/db/migrations/2023-04-20-01 Titan support.ts @@ -0,0 +1,31 @@ +import { Kysely, sql } from 'kysely' +import { Client } from 'pg' + +const pgClient = new Client({ + host: process.env.POSTGRES_HOST, + database: process.env.POSTGRES_DATABASE, + user: process.env.POSTGRES_USER, + password: process.env.POSTGRES_PASSWORD +}) + +export async function up(db: Kysely): Promise { + await pgClient.connect() + await pgClient.query(`ALTER TABLE kill ADD COLUMN IF NOT EXISTS attacker_titan character varying NULL;`) + await pgClient.query(`UPDATE kill SET attacker_titan = 'scorch' WHERE (cause_of_death = 'mp_titancore_flame_wave_secondary' OR cause_of_death = 'mp_titancore_flame_wave' OR cause_of_death = 'mp_titancore_flame_wall' OR cause_of_death = 'mp_titanweapon_meteor_thermite' OR cause_of_death = 'mp_titanweapon_heat_shield' OR cause_of_death = 'titan_punch_scorch' OR cause_of_death = 'mp_titanweapon_meteor')`) + await pgClient.query(`UPDATE kill SET attacker_titan = 'ronin' WHERE (cause_of_death = 'mp_titanweapon_arc_wave' OR cause_of_death = 'mp_titancore_shift_core' OR cause_of_death = 'titan_sword' OR cause_of_death = 'mp_titanweapon_leadwall')`) + await pgClient.query(`UPDATE kill SET attacker_titan = 'ion' WHERE (cause_of_death = 'titan_punch_ion' OR cause_of_death = 'mp_titanweapon_vortex_shield_ion' OR cause_of_death = 'mp_titancore_laser_cannon' OR cause_of_death = 'mp_titanability_laser_trip' OR cause_of_death = 'mp_titanweapon_laser_lite')`) + await pgClient.query(`UPDATE kill SET attacker_titan = 'tone' WHERE (cause_of_death = 'mp_titancore_salvo_core' OR cause_of_death = 'titan_punch_tone' OR cause_of_death = 'mp_titanweapon_salvo_rockets' OR cause_of_death = 'mp_titanweapon_sticky_40mm')`) + await pgClient.query(`UPDATE kill SET attacker_titan = 'northstar' WHERE (cause_of_death = 'mp_titanability_slow_trap' OR cause_of_death = 'mp_titanweapon_flightcore_rockets' OR cause_of_death = 'titan_punch_northstar' OR cause_of_death = 'mp_titanweapon_sniper')`) + await pgClient.query(`UPDATE kill SET attacker_titan = 'legion' WHERE (cause_of_death = 'titan_punch_legion' OR cause_of_death = 'mp_titanweapon_predator_cannon')`) + await pgClient.query(`UPDATE kill SET attacker_titan = 'vanguard' WHERE (cause_of_death = 'mp_titanweapon_dumbfire_rockets' OR cause_of_death = 'titan_punch_vanguard' OR cause_of_death = 'mp_titanweapon_tracker_rockets' OR cause_of_death = 'mp_titanweapon_particle_accelerator' OR cause_of_death = 'mp_titanweapon_xo16_vanguard')`) + await pgClient.query(`ALTER TABLE kill ADD COLUMN IF NOT EXISTS victim_titan character varying NULL;`) + //Update the hosts column once the hoster table is manually updated + await pgClient.end() +} + +export async function down(db: Kysely): Promise { + await pgClient.connect() + pgClient.query('ALTER TABLE kill DROP COLUMN IF EXISTS attacker_titan') + pgClient.query('ALTER TABLE kill DROP COLUMN IF EXISTS victim_titan') + await pgClient.end() +} diff --git a/src/db/model.ts b/src/db/model.ts index 21e992d..6939787 100644 --- a/src/db/model.ts +++ b/src/db/model.ts @@ -37,6 +37,7 @@ export interface KillTable { victim_offhand_weapon_2: number cause_of_death: string distance: number + titan?: string } /* interface PlayerTable { diff --git a/src/server/server.ts b/src/server/server.ts index 3a05183..1e6ca69 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -114,7 +114,9 @@ router.post( 'victim_weapon_1', 'victim_weapon_2', 'victim_weapon_3', - 'cause_of_death' + 'cause_of_death', + 'victim_titan', + 'attacker_titan' ], 'must be composed of a maximum of 50 valid ascii characters' ) From b7e8738ca29edbecb3757b2ec1d9a97858f22c96 Mon Sep 17 00:00:00 2001 From: legonzaur Date: Thu, 20 Apr 2023 14:58:06 +0200 Subject: [PATCH 03/22] V2 documentation. Closes #8 --- docs/index.html | 91 ++++++---- docs/v2.yml | 447 ++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 2 +- 3 files changed, 510 insertions(+), 30 deletions(-) create mode 100644 docs/v2.yml diff --git a/docs/index.html b/docs/index.html index 59ff5c0..bd26102 100644 --- a/docs/index.html +++ b/docs/index.html @@ -14,7 +14,9 @@