From 91c22f3ae1ba90211fb3b852ee631c37e6c05c50 Mon Sep 17 00:00:00 2001 From: legonzaur Date: Sat, 29 Apr 2023 10:10:35 +0200 Subject: [PATCH 1/2] fix name of some weapons --- .../migrations/2023-04-29-01 Weapon Rename.ts | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/db/migrations/2023-04-29-01 Weapon Rename.ts diff --git a/src/db/migrations/2023-04-29-01 Weapon Rename.ts b/src/db/migrations/2023-04-29-01 Weapon Rename.ts new file mode 100644 index 0000000..8075a63 --- /dev/null +++ b/src/db/migrations/2023-04-29-01 Weapon Rename.ts @@ -0,0 +1,64 @@ +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 +}) + +const weapons = { + titan_sword: 'melee_titan_sword', + yh803_bullet: 'mp_weapon_yh803_bullet', + titan_punch_scorch: 'melee_titan_punch_scorch', + titan_punch_tone: 'melee_titan_punch_tone', + titan_punch_ion: "melee_titan_punch_ion", + titan_punch_vanguard: "melee_titan_punch_vanguard", + titan_punch_legion: "melee_titan_punch_legion", + titan_punch_northstar: "melee_titan_punch_northstar", +} + +export async function up(db: Kysely): Promise { + await pgClient.connect() + await Promise.all( + Object.entries(weapons).map(async (e) => { + console.log('update ' + e[0]) + await pgClient.query( + `UPDATE KILL SET cause_of_death = '${e[1]}' WHERE cause_of_death = '${e[0]}';` + ) + await pgClient.query( + `UPDATE KILL SET attacker_current_weapon = '${e[1]}' WHERE attacker_current_weapon = '${e[0]}';` + ) + await pgClient.query( + `UPDATE KILL SET attacker_weapon_1 = '${e[1]}' WHERE attacker_weapon_1 = '${e[0]}';` + ) + await pgClient.query( + `UPDATE KILL SET attacker_weapon_2 = '${e[1]}' WHERE attacker_weapon_2 = '${e[0]}';` + ) + await pgClient.query( + `UPDATE KILL SET attacker_weapon_3 = '${e[1]}' WHERE attacker_weapon_3 = '${e[0]}';` + ) + await pgClient.query( + `UPDATE KILL SET victim_current_weapon = '${e[1]}' WHERE victim_current_weapon = '${e[0]}';` + ) + await pgClient.query( + `UPDATE KILL SET victim_weapon_1 = '${e[1]}' WHERE victim_weapon_1 = '${e[0]}';` + ) + await pgClient.query( + `UPDATE KILL SET victim_weapon_2 = '${e[1]}' WHERE victim_weapon_2 = '${e[0]}';` + ) + await pgClient.query( + `UPDATE KILL SET victim_weapon_3 = '${e[1]}' WHERE victim_weapon_3 = '${e[0]}';` + ) + console.log('weapon ' + e[1] + ' updated') + }) + ) + + console.log('end') + + //Update the hosts column once the hoster table is manually updated + await pgClient.end() +} + +export async function down(db: Kysely): Promise { } From a313793b9cd23b91d313dcc66cd63e2755997ad8 Mon Sep 17 00:00:00 2001 From: legonzaur Date: Tue, 2 May 2023 11:14:45 +0200 Subject: [PATCH 2/2] hotfix for servername length --- src/server/server.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/server/server.ts b/src/server/server.ts index c6ed01f..c67c7af 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -97,7 +97,6 @@ router.post( .withMessage('must be a valid float'), body( [ - 'servername', 'attacker_id', 'victim_id', 'killstat_version', @@ -127,6 +126,9 @@ router.post( .isString() .isLength({ max: 50 }) .isAscii(), + body('servername',).isString() + .isLength({ max: 100 }) + .isAscii(), body(['distance', 'game_time'], 'must be postitive floats').isFloat({ min: 0 }),