From c4145b31e55a7f74e7a44965c4759707fc8b8965 Mon Sep 17 00:00:00 2001 From: themrrobert <10122432+themrrobert@users.noreply.github.com> Date: Tue, 18 Jun 2024 06:51:05 -0700 Subject: [PATCH] Add economy tracking for GE Bank GP + Big Alchables. (#5918) --- prisma/schema.prisma | 2 ++ src/lib/analytics.ts | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index c38c692aca..530ddd601b 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -41,6 +41,8 @@ model Analytic { ironMinionsCount Int? totalSacrificed BigInt? totalGP BigInt? + totalGeGp BigInt? + totalBigAlchGp BigInt? dicingBank BigInt? duelTaxBank BigInt? dailiesAmount BigInt? diff --git a/src/lib/analytics.ts b/src/lib/analytics.ts index be29bc33b8..d43aead457 100644 --- a/src/lib/analytics.ts +++ b/src/lib/analytics.ts @@ -2,6 +2,7 @@ import { ActivityGroup, globalConfig } from '../lib/constants'; import { prisma } from '../lib/settings/prisma'; import { GroupMonsterActivityTaskOptions } from '../lib/types/minions'; import { taskGroupFromActivity } from '../lib/util/taskGroupFromActivity'; +import { getItem } from './util/getOSItem'; async function calculateMinionTaskCounts() { const minionTaskCounts: Record = { @@ -47,8 +48,21 @@ export async function analyticsTick() { ) ).map((result: any) => parseInt(result[0].count)) as number[]; + const artifact = getItem('Magical artifact')!; + const statuette = getItem('Demon statuette')!; + + const [totalGeGp, totalArtifactGp, totalDemonStatuetteGp] = ( + await Promise.all( + [ + 'SELECT quantity AS val FROM ge_bank WHERE item_id = 995', + `SELECT COALESCE(SUM((bank->>'${artifact.id}')::bigint) * ${artifact.highalch}, 0) as val FROM users WHERE bank->>'${artifact.id}' IS NOT NULL`, + `SELECT COALESCE(SUM((bank->>'${statuette.id}')::bigint) * ${statuette.highalch}, 0) as val FROM users WHERE bank->>'${artifact.id}' IS NOT NULL` + ].map(q => prisma.$queryRawUnsafe<{ val: bigint }[]>(q)) + ) + ).map((v: { val: bigint }[]) => BigInt(v[0].val)); + const taskCounts = await calculateMinionTaskCounts(); - const currentClientSettings = await await prisma.clientStorage.findFirst({ + const currentClientSettings = await prisma.clientStorage.findFirst({ where: { id: globalConfig.clientID }, @@ -84,6 +98,8 @@ export async function analyticsTick() { minionsCount: numberOfMinions, totalSacrificed, totalGP, + totalGeGp, + totalBigAlchGp: totalDemonStatuetteGp + totalArtifactGp, dicingBank: currentClientSettings.economyStats_dicingBank, duelTaxBank: currentClientSettings.economyStats_duelTaxBank, dailiesAmount: currentClientSettings.economyStats_dailiesAmount,