From fb9889964bfd7954b9dcf67aae670259ba5960f6 Mon Sep 17 00:00:00 2001 From: gc <30398469+gc@users.noreply.github.com> Date: Wed, 28 Feb 2024 02:41:10 +1100 Subject: [PATCH 1/3] Update robochimp schema --- prisma/robochimp.prisma | 3 +++ 1 file changed, 3 insertions(+) diff --git a/prisma/robochimp.prisma b/prisma/robochimp.prisma index 9e237177e2..28c623bb44 100644 --- a/prisma/robochimp.prisma +++ b/prisma/robochimp.prisma @@ -57,6 +57,9 @@ model User { store_bitfield Int[] + testing_points Float @default(0) + testing_points_balance Float @default(0) + @@map("user") } From 3baa510e64bab3a6ba9ce1984cff5ca5b2685939 Mon Sep 17 00:00:00 2001 From: gc <30398469+gc@users.noreply.github.com> Date: Wed, 28 Feb 2024 02:42:10 +1100 Subject: [PATCH 2/3] Add manual analytics tick command --- src/mahoji/commands/rp.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/mahoji/commands/rp.ts b/src/mahoji/commands/rp.ts index 9b653f75c6..865218b7b8 100644 --- a/src/mahoji/commands/rp.ts +++ b/src/mahoji/commands/rp.ts @@ -9,6 +9,7 @@ import { Bank } from 'oldschooljs'; import { Item } from 'oldschooljs/dist/meta/types'; import { ADMIN_IDS, OWNER_IDS, production, SupportServer } from '../../config'; +import { analyticsTick } from '../../lib/analytics'; import { BitField, Channel } from '../../lib/constants'; import { GearSetupType } from '../../lib/gear/types'; import { GrandExchange } from '../../lib/grandExchange'; @@ -78,6 +79,12 @@ export const rpCommand: OSBMahojiCommand = { name: 'view_all_items', description: 'View all item IDs present in banks/cls.', options: [] + }, + { + type: ApplicationCommandOptionType.Subcommand, + name: 'analytics_tick', + description: 'analyticsTick.', + options: [] } ] }, @@ -309,6 +316,7 @@ export const rpCommand: OSBMahojiCommand = { validate_ge?: {}; patreon_reset?: {}; view_all_items?: {}; + analytics_tick?: {}; }; player?: { viewbank?: { user: MahojiUserOption; json?: boolean }; @@ -355,6 +363,10 @@ export const rpCommand: OSBMahojiCommand = { } return 'Something was invalid. Check logs!'; } + if (options.action?.analytics_tick) { + await analyticsTick(); + return 'Finished.'; + } if (options.action?.view_all_items) { const result = await prisma.$queryRawUnsafe< From ea735c1b49441ada20db33a25957521c5a9f4605 Mon Sep 17 00:00:00 2001 From: gc <30398469+gc@users.noreply.github.com> Date: Wed, 28 Feb 2024 02:47:01 +1100 Subject: [PATCH 3/3] Fix bigint bug --- src/lib/analytics.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/analytics.ts b/src/lib/analytics.ts index 1d60da2474..629e2a067d 100644 --- a/src/lib/analytics.ts +++ b/src/lib/analytics.ts @@ -40,7 +40,7 @@ export async function analyticsTick() { await Promise.all( [ 'SELECT COUNT(*)::int FROM users WHERE "minion.hasBought" = true;', - 'SELECT SUM("sacrificedValue")::int AS count FROM users;', + 'SELECT SUM("sacrificedValue") AS count FROM users;', 'SELECT COUNT(*)::int FROM users WHERE "minion.ironman" = true;', 'SELECT SUM("GP") AS count FROM users;' ].map(query => prisma.$queryRawUnsafe(query))