diff --git a/src/mahoji/commands/admin.ts b/src/mahoji/commands/admin.ts index a459680ca7..f1eab35b75 100644 --- a/src/mahoji/commands/admin.ts +++ b/src/mahoji/commands/admin.ts @@ -322,7 +322,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 ( @@ -440,13 +440,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 @@ -474,7 +474,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 @@ -483,7 +483,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 6f46eba571..c185763bee 100644 --- a/src/mahoji/lib/abstracted_commands/statCommand.ts +++ b/src/mahoji/lib/abstracted_commands/statCommand.ts @@ -504,7 +504,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)} @@ -523,7 +523,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)}