Skip to content

Commit

Permalink
Merge branch 'master' into bso
Browse files Browse the repository at this point in the history
  • Loading branch information
gc committed Feb 27, 2024
2 parents 9c02a0f + 64e4e46 commit b6c9ccf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/mahoji/commands/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/mahoji/lib/abstracted_commands/statCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
Expand All @@ -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)}
Expand Down

0 comments on commit b6c9ccf

Please sign in to comment.