Skip to content

Commit

Permalink
Add economy tracking for GE Bank + Big Alchables.
Browse files Browse the repository at this point in the history
  • Loading branch information
themrrobert committed Jun 13, 2024
1 parent 29f1ca9 commit b720e32
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(

Check failure on line 55 in src/lib/analytics.ts

View workflow job for this annotation

GitHub Actions / Node v18.12.0 - ubuntu-latest

tests/integration/misc.test.ts > Integration Misc > Analytics

PrismaClientKnownRequestError: Invalid `prisma.$queryRawUnsafe()` invocation: Raw query failed. Code: `42601`. Message: `ERROR: unterminated quoted string at or near "'73140)::bigint) * 80000000 as statuette_val"` ❯ In.handleRequestError node_modules/@prisma/client/runtime/library.js:122:6854 ❯ In.handleAndLogRequestError node_modules/@prisma/client/runtime/library.js:122:6188 ❯ In.request node_modules/@prisma/client/runtime/library.js:122:5896 ❯ l node_modules/@prisma/client/runtime/library.js:127:11167 ❯ Module.analyticsTick src/lib/analytics.ts:55:3 ❯ tests/integration/misc.test.ts:17:3 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { code: 'P2010', clientVersion: '5.13.0', meta: { code: '42601', message: 'ERROR: unterminated quoted string at or near "\'73140)::bigint) * 80000000 as statuette_val"' }, batchRequestIdx: undefined }

Check failure on line 55 in src/lib/analytics.ts

View workflow job for this annotation

GitHub Actions / Node v20 - ubuntu-latest

tests/integration/misc.test.ts > Integration Misc > Analytics

PrismaClientKnownRequestError: Invalid `prisma.$queryRawUnsafe()` invocation: Raw query failed. Code: `42601`. Message: `ERROR: unterminated quoted string at or near "'73140)::bigint) * 80000000 as statuette_val"` ❯ In.handleRequestError node_modules/@prisma/client/runtime/library.js:122:6854 ❯ In.handleAndLogRequestError node_modules/@prisma/client/runtime/library.js:122:6188 ❯ In.request node_modules/@prisma/client/runtime/library.js:122:5896 ❯ l node_modules/@prisma/client/runtime/library.js:127:11167 ❯ Module.analyticsTick src/lib/analytics.ts:55:3 ❯ tests/integration/misc.test.ts:17:3 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { code: 'P2010', clientVersion: '5.13.0', meta: { code: '42601', message: 'ERROR: unterminated quoted string at or near "\'73140)::bigint) * 80000000 as statuette_val"' }, batchRequestIdx: undefined }
[
'SELECT quantity AS ge_gp FROM ge_bank WHERE item_id = 995',
`SELECT SUM((bank->>'${artifact.id})::bigint) * ${artifact.highalch} as artifact_val`,
`SELECT SUM((bank->>'${statuette.id})::bigint) * ${statuette.highalch} as statuette_val`
].map(q => prisma.$queryRawUnsafe<string>(q))
)
).map((v: string) => BigInt(v));

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 b720e32

Please sign in to comment.