From 442b89421708fc67b89648dde8eaa33292e8ec14 Mon Sep 17 00:00:00 2001 From: Legonzaur Date: Sun, 13 Aug 2023 16:12:16 +0000 Subject: [PATCH] compilation not working --- package-lock.json | 3 +- src/db | 2 +- src/templates/server.ts | 4 +-- src/types.ts | 16 +++++------ src/utils.ts | 63 +++++++++++++++++++++++++---------------- 5 files changed, 50 insertions(+), 38 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2b3589e..39ff27f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,10 +1,9 @@ { - "name": "ToneAPI_backend", + "name": "Stat_Tracker_Server", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "ToneAPI_backend", "dependencies": { "@types/ws": "^8.5.4", "cors": "^2.8.5", diff --git a/src/db b/src/db index dc5325c..cf5a295 160000 --- a/src/db +++ b/src/db @@ -1 +1 @@ -Subproject commit dc5325c23aa31f85125b35df5441789ddc71e675 +Subproject commit cf5a2959cf0b3d6a6dd0b38341d10a35d56999b3 diff --git a/src/templates/server.ts b/src/templates/server.ts index b621f84..beabbe7 100644 --- a/src/templates/server.ts +++ b/src/templates/server.ts @@ -86,7 +86,7 @@ type RequestBody = Request<{}, {}, T>; router.post( "/kill", - validateBody(typia.createValidate()), + // validateBody(typia.createValidate()), (req: RequestBody, res: Response) => { void (async () => { const host_id = res.locals.host_id; @@ -190,7 +190,7 @@ router.post( router.post( "/match", - validateBody(typia.createValidate()), + // validateBody(typia.createValidate()), (req: RequestBody, res: Response) => { void (async () => { const host_id = res.locals.host_id; diff --git a/src/types.ts b/src/types.ts index 9baa4b9..77a3e57 100644 --- a/src/types.ts +++ b/src/types.ts @@ -7,14 +7,14 @@ type WeaponKillData = { }; export type LoadoutKillData = { - ordnance: WeaponKillData | null; - secondary: WeaponKillData | null; - primary: WeaponKillData | null; - tactical: WeaponKillData | null; - anti_titan: WeaponKillData | null; - passive1:string | null; - passive2:string | null; - titan: string | null; + ordnance: WeaponKillData | undefined; + secondary: WeaponKillData | undefined; + primary: WeaponKillData | undefined; + tactical: WeaponKillData | undefined; + anti_titan: WeaponKillData | undefined; + passive1:string | undefined; + passive2:string | undefined; + titan: string | undefined; }; type PlayerKillData = { diff --git a/src/utils.ts b/src/utils.ts index 113385e..7030693 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -115,7 +115,7 @@ export async function checkOrCreateTitan(titan_id: string | null, trx?:Transacti .execute(); } } - + await createOrRunInTransaction(runner, trx) } @@ -128,40 +128,53 @@ export async function checkOrCreateLoadout(loadoutData: LoadoutKillData) { let loadout = await trx .selectFrom("ToneAPI_v3.loadout") .select("ToneAPI_v3.loadout.loadout_id") - .where("primary_weapon", "=", loadoutData.primary?.id ?? null) - .where("primary_mod_id", "=", loadoutData.primary?.mods ?? null) - .where("secondary_weapon", "=", loadoutData.secondary?.id ?? null) - .where("secondary_mod_id", "=", loadoutData.secondary?.mods ?? null) - .where("anti_titan_weapon", "=", loadoutData.anti_titan?.id ?? null) - .where("anti_titan_mod_id", "=", loadoutData.anti_titan?.mods ?? null) - .where( - "ToneAPI_v3.loadout.ordnance", - "=", - loadoutData.ordnance?.id ?? null - ) - .where( - "ToneAPI_v3.loadout.tactical", - "=", - loadoutData.tactical?.id ?? null - ) - .where("ToneAPI_v3.loadout.pilot_passive_1", "=", loadoutData.passive1) - .where("ToneAPI_v3.loadout.pilot_passive_2", "=", loadoutData.passive2) - .where("ToneAPI_v3.loadout.titan_id", "=", loadoutData.titan) + .$if(loadoutData.primary?.id !== undefined, (qb)=>qb.where("primary_weapon", "=", loadoutData.primary!.id)) + .$if(loadoutData.primary?.id == undefined, (qb)=>qb.where("primary_weapon", "is", null)) + .$if(loadoutData.primary?.mods !== undefined, (qb)=>qb.where("primary_mod_id", "=", loadoutData.primary!.mods)) + .$if(loadoutData.primary?.mods == undefined, (qb)=>qb.where("primary_mod_id", "is", null)) + .$if(loadoutData.secondary?.id !== undefined, (qb)=>qb.where("secondary_weapon", "=", loadoutData.secondary!.id)) + .$if(loadoutData.secondary?.id == undefined, (qb)=>qb.where("secondary_weapon", "is", null)) + .$if(loadoutData.secondary?.mods !== undefined, (qb)=>qb.where("secondary_mod_id", "=", loadoutData.secondary!.mods)) + .$if(loadoutData.secondary?.mods == undefined, (qb)=>qb.where("secondary_mod_id", "is", null)) + .$if(loadoutData.anti_titan?.id !== undefined, (qb)=>qb.where("anti_titan_weapon", "=", loadoutData.anti_titan!.id)) + .$if(loadoutData.anti_titan?.id == undefined, (qb)=>qb.where("anti_titan_weapon", "is", null)) + .$if(loadoutData.anti_titan?.mods !== undefined, (qb)=>qb.where("anti_titan_mod_id", "=", loadoutData.anti_titan!.mods)) + .$if(loadoutData.anti_titan?.mods == undefined, (qb)=>qb.where("anti_titan_mod_id", "is", null)) + + .$if(loadoutData.ordnance?.id !== undefined, (qb)=>qb.where("ordnance", "=", loadoutData.ordnance!.id)) + .$if(loadoutData.ordnance?.id == undefined, (qb)=>qb.where("ordnance", "is", null)) + + .$if(loadoutData.ordnance?.id !== undefined, (qb)=>qb.where("ordnance", "=", loadoutData.ordnance!.id)) + .$if(loadoutData.ordnance?.id == undefined, (qb)=>qb.where("ordnance", "is", null)) + + .$if(loadoutData.tactical?.id !== undefined, (qb)=>qb.where("tactical", "=", loadoutData.tactical!.id)) + .$if(loadoutData.tactical?.id == undefined, (qb)=>qb.where("tactical", "is", null)) + + + .$if(loadoutData.passive1 !== undefined, (qb)=>qb.where("pilot_passive_1", "=", loadoutData.passive1!)) + .$if(loadoutData.passive1 == undefined, (qb)=>qb.where("pilot_passive_1", "is", null)) + .$if(loadoutData.passive2 !== undefined, (qb)=>qb.where("pilot_passive_2", "=", loadoutData.passive2!)) + .$if(loadoutData.passive2 == undefined, (qb)=>qb.where("pilot_passive_2", "is", null)) + .$if(loadoutData.titan !== undefined, (qb)=>qb.where("titan_id", "=", loadoutData.titan!)) + .$if(loadoutData.titan == undefined, (qb)=>qb.where("titan_id", "is", null)) + .executeTakeFirst(); if (!loadout) { - if (loadoutData.primary !== null) { + if (loadoutData.primary !== undefined) { await checkOrCreateWeaponMods(loadoutData.primary, trx); } - if (loadoutData.secondary !== null) { + if (loadoutData.secondary !== undefined) { await checkOrCreateWeaponMods(loadoutData.secondary, trx); } - if (loadoutData.anti_titan !== null) { + if (loadoutData.anti_titan !== undefined) { await checkOrCreateWeaponMods(loadoutData.anti_titan, trx); } - if (loadoutData.ordnance !== null) { + if (loadoutData.ordnance !== undefined) { await checkOrCreateWeapon(loadoutData.ordnance.id, trx); } - await checkOrCreateTitan(loadoutData.titan, trx); + if (loadoutData.titan !== undefined) { + await checkOrCreateTitan(loadoutData.titan, trx); + } const result = await trx .insertInto("ToneAPI_v3.loadout") .values({