From 64e4e46f15b8325967d8599213dcee96ee9dda0d Mon Sep 17 00:00:00 2001 From: gc <30398469+gc@users.noreply.github.com> Date: Tue, 27 Feb 2024 16:21:40 +1100 Subject: [PATCH] Bigint fixes --- src/mahoji/commands/admin.ts | 12 ++++++------ src/mahoji/lib/abstracted_commands/statCommand.ts | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/mahoji/commands/admin.ts b/src/mahoji/commands/admin.ts index 097731b97c..320962f9fc 100644 --- a/src/mahoji/commands/admin.ts +++ b/src/mahoji/commands/admin.ts @@ -289,7 +289,7 @@ AND ("gear.melee" IS NOT NULL OR >(`SELECT (blowpipe->>'scales')::int AS scales, (blowpipe->>'dartID')::int AS dart, (blowpipe->>'dartQuantity')::int AS qty FROM users WHERE blowpipe iS NOT NULL and (blowpipe->>'dartQuantity')::int != 0;`), - prisma.$queryRawUnsafe<{ sum: number }[]>('SELECT SUM("GP")::int FROM users;'), + prisma.$queryRawUnsafe<{ sum: number }[]>('SELECT SUM("GP") FROM users;'), prisma.$queryRawUnsafe<{ banks: ItemBank }[]>(`SELECT json_object_agg(itemID, itemQTY)::jsonb as banks from ( @@ -407,13 +407,13 @@ The next buy limit reset is at: ${buyLimitInterval.nextResetStr}, it resets ever { name: 'Buy GP Sinks', run: async () => { - const result = await prisma.$queryRawUnsafe<{ item_id: string; total_gp_spent: number }[]>(`SELECT + const result = await prisma.$queryRawUnsafe<{ item_id: string; total_gp_spent: bigint }[]>(`SELECT key AS item_id, - sum((cost_gp / total_items) * value::integer)::int AS total_gp_spent + sum((cost_gp / total_items) * value::integer) AS total_gp_spent FROM buy_command_transaction, json_each_text(loot_bank), - (SELECT id, sum(value::integer)::int as total_items FROM buy_command_transaction, json_each_text(loot_bank) GROUP BY id) subquery + (SELECT id, sum(value::integer) as total_items FROM buy_command_transaction, json_each_text(loot_bank) GROUP BY id) subquery WHERE buy_command_transaction.id = subquery.id GROUP BY @@ -441,7 +441,7 @@ LIMIT run: async () => { const result = await prisma.$queryRawUnsafe< { item_id: number; gp: number }[] - >(`select item_id, sum(gp_received)::int as gp + >(`select item_id, sum(gp_received) as gp from bot_item_sell group by item_id order by gp desc @@ -450,7 +450,7 @@ limit 80; const totalGPGivenOut = await prisma.$queryRawUnsafe< { total_gp_given_out: number }[] - >(`select sum(gp_received)::int as total_gp_given_out + >(`select sum(gp_received) as total_gp_given_out from bot_item_sell;`); return { diff --git a/src/mahoji/lib/abstracted_commands/statCommand.ts b/src/mahoji/lib/abstracted_commands/statCommand.ts index bb339a7ee4..ecca38d52a 100644 --- a/src/mahoji/lib/abstracted_commands/statCommand.ts +++ b/src/mahoji/lib/abstracted_commands/statCommand.ts @@ -338,7 +338,7 @@ GROUP BY type;`); perkTierNeeded: PerkTier.Four, run: async (user: MUser) => { const result: { type: activity_type_enum; hours: number }[] = - await prisma.$queryRawUnsafe(`SELECT type, sum(duration) / ${Time.Hour} AS hours + await prisma.$queryRawUnsafe(`SELECT type, sum(duration)::int / ${Time.Hour} AS hours FROM activity WHERE completed = true AND user_id = ${BigInt(user.id)} @@ -357,7 +357,7 @@ GROUP BY type;`); perkTierNeeded: PerkTier.Four, run: async (user: MUser) => { const result: { id: number; kc: number }[] = - await prisma.$queryRawUnsafe(`SELECT (data->>'monsterID')::int as id, SUM((data->>'quantity')::int) AS kc + await prisma.$queryRawUnsafe(`SELECT (data->>'monsterID')::int as id, SUM((data->>'quantity')::int)::int AS kc FROM activity WHERE completed = true AND user_id = ${BigInt(user.id)}