Skip to content

Commit

Permalink
Add economy tracking for GE Bank GP + Big Alchables. (#5918)
Browse files Browse the repository at this point in the history
  • Loading branch information
themrrobert authored Jun 18, 2024
1 parent b932c05 commit c4145b3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ model Analytic {
ironMinionsCount Int?
totalSacrificed BigInt?
totalGP BigInt?
totalGeGp BigInt?
totalBigAlchGp BigInt?
dicingBank BigInt?
duelTaxBank BigInt?
dailiesAmount BigInt?
Expand Down
18 changes: 17 additions & 1 deletion src/lib/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ActivityGroup, number> = {
Expand Down Expand Up @@ -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
},
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit c4145b3

Please sign in to comment.