Skip to content

Commit

Permalink
Merge branch 'master' into cat-ears
Browse files Browse the repository at this point in the history
  • Loading branch information
TastyPumPum authored Feb 27, 2024
2 parents e9a298c + ea735c1 commit 55f08ee
Show file tree
Hide file tree
Showing 104 changed files with 1,908 additions and 2,406 deletions.
9 changes: 9 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
TZ="UTC"
ROBOCHIMP_DATABASE_URL=postgresql://postgres:postgres@localhost:5436/robochimp_integration_test?connection_limit=1000
DATABASE_URL=postgresql://postgres:postgres@localhost:5435/osb_integration_test?pool_timeout=120&connection_limit=1000
PATREON_CAMPAIGN_ID=1234
PATREON_TOKEN=asdfasdfasdf
PATREON_WEBHOOK_SECRET=asdfasdfasdf
HTTP_PORT=7373
CLIENT_ID=111398433321891634
# PRISMA_CLIENT_ENGINE_TYPE=binary
69 changes: 0 additions & 69 deletions .github/workflows/codequality.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ jobs:
test:
name: Node v${{ matrix.node_version }} - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 10
strategy:
matrix:
node_version: [18.12.0, 20]
os: [ubuntu-latest]

steps:
- name: Install System Packages
run: sudo apt-get install -y build-essential libpq-dev

- name: Checkout Project
uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node_version }}
Expand All @@ -37,6 +41,6 @@ jobs:
cp config.example.ts config.ts &&
popd
- name: Copy env
run: cp .env.example .env
run: cp .env.test .env
- name: Test
run: yarn test:integration
12 changes: 11 additions & 1 deletion .github/workflows/test.yml → .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
test:
name: Node v${{ matrix.node_version }} - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 10
strategy:
matrix:
node_version: [18.12.0, 20]
Expand All @@ -37,9 +38,18 @@ jobs:
cp config.example.ts config.ts &&
popd
- name: Copy env
run: cp .env.example .env
run: cp .env.test .env
- name: Generate Prisma Client
run: yarn gen
- name: Run ESLint on changed files
uses: tj-actions/eslint-changed-files@v21
with:
skip_annotations: true
config_path: ".eslintrc.json"
ignore_path: ".eslintignore"
file_extensions: |
**/*.ts
**/*.tsx
- name: Build
run: yarn build
- name: Test
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version: "3.9"
services:
osb:
image: postgres:13-alpine
command: -c 'max_connections=100'
command: -c 'max_connections=1000'
restart: always
container_name: osb_database
ports:
Expand All @@ -18,7 +18,7 @@ services:

robochimp:
image: postgres:13-alpine
command: -c 'max_connections=100'
command: -c 'max_connections=1000'
restart: always
container_name: robochimp_database
ports:
Expand Down
40 changes: 19 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
"wipedist": "rimraf \"dist/\"",
"start": "yarn build && concurrently \"tsc -w -p src\" \"node dist/\"",
"test": "concurrently \"tsc -p src\" \"yarn test:lint\" \"yarn test:unit\"",
"test:lint": "eslint *.ts \"{src,tests}/**/*.ts\"",
"test:lint": "eslint --quiet *.ts \"{src,tests}/**/*.ts\"",
"test:unit": "vitest run --coverage --config vitest.unit.config.ts",
"dev": "yarn wipedist && tsc -w -p src",
"test:watch": "vitest --config vitest.unit.config.ts --coverage",
"test:integration": "ts-node ./src/scripts/integration-tests.ts",
"prebuild:scripts": "ts-node -T ./src/scripts/render-creatables-file.ts",
"test:integration": "tsx ./src/scripts/integration-tests.ts",
"prebuild:scripts": "tsx ./src/scripts/render-creatables-file.ts",
"build:esbuild": "esbuild --bundle src/index.ts --outdir=dist --platform=node --loader:.node=file --external:canvas"
},
"dependencies": {
Expand All @@ -23,21 +23,19 @@
"@fastify/sensible": "^5.2.0",
"@napi-rs/canvas": "0.1.38",
"@octokit/graphql": "^4.8.0",
"@oldschoolgg/toolkit": "^0.0.23",
"@prisma/client": "^3.15.1",
"@oldschoolgg/toolkit": "^0.0.24",
"@prisma/client": "^5.10.2",
"@sapphire/stopwatch": "^1.4.0",
"@sapphire/time-utilities": "^1.6.0",
"@sentry/node": "^7.69.0",
"bufferutil": "^4.0.7",
"@sentry/node": "^7.102.0",
"bufferutil": "^4.0.8",
"chart.js": "^3.7.0",
"chartjs-node-canvas": "github:gc/ChartjsNodeCanvas#a598b6dd27c44351f235bca07ca4ee660121f289",
"chartjs-plugin-datalabels": "^2.0.0",
"chokidar": "^3.5.3",
"deep-equal": "^2.2.2",
"deep-equal": "^2.2.3",
"deepmerge": "^4.3.1",
"discord.js": "^14.13.0",
"dotenv": "^16.0.3",
"dotenv-cli": "^7.1.0",
"e": "^0.2.33",
"fastify": "^4.14.1",
"fastify-raw-body": "^4.2.0",
Expand All @@ -46,17 +44,18 @@
"lru-cache": "^8.0.0",
"mahoji": "^0.0.7",
"murmurhash": "^2.0.1",
"node-cron": "^3.0.2",
"node-cron": "^3.0.3",
"node-fetch": "^2.6.7",
"oldschooljs": "^2.3.8",
"oldschooljs": "^2.5.1",
"p-queue": "^6.6.2",
"piscina": "^3.2.0",
"piscina": "^4.3.2",
"random-js": "^2.1.0",
"simple-statistics": "^7.8.3",
"sonic-boom": "^3.8.0",
"table": "^6.8.0",
"table": "^6.8.1",
"tsx": "^4.7.1",
"zlib-sync": "^0.1.9",
"zod": "^3.22.3"
"zod": "^3.22.4"
},
"devDependencies": {
"@oldschoolgg/eslint-config": "^2.0.13",
Expand All @@ -69,11 +68,11 @@
"@types/node": "^14.18.12",
"@types/node-cron": "^3.0.7",
"@types/node-fetch": "^2.6.1",
"@types/table": "^6.3.2",
"@typescript-eslint/eslint-plugin": "^5.41.0",
"@typescript-eslint/parser": "^5.41.0",
"@vitest/coverage-c8": "^0.31.0",
"@vitest/coverage-v8": "^1.3.1",
"concurrently": "^7.6.0",
"dotenv-cli": "^7.3.0",
"esbuild": "^0.19.5",
"eslint": "^8.36.0",
"eslint-config-prettier": "^8.5.0",
Expand All @@ -84,12 +83,11 @@
"jest-image-snapshot": "^6.2.0",
"madge": "^6.0.0",
"prettier": "^2.7.1",
"prisma": "^3.15.1",
"prisma": "^5.10.2",
"rimraf": "^4.4.0",
"source-map-support": "^0.5.21",
"ts-node": "^10.9.1",
"typescript": "^5.0.2",
"vitest": "^0.31.0"
"typescript": "5.0.2",
"vitest": "^1.3.1"
},
"engines": {
"node": ">=18.12.0"
Expand Down
3 changes: 3 additions & 0 deletions prisma/robochimp.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ model User {
store_bitfield Int[]
testing_points Float @default(0)
testing_points_balance Float @default(0)
@@map("user")
}

Expand Down
5 changes: 2 additions & 3 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,6 @@ model User {
farmingPatches_flower Json? @map("farmingPatches.flower") @db.Json
farmingPatches_mushroom Json? @map("farmingPatches.mushroom") @db.Json
farmingPatches_belladonna Json? @map("farmingPatches.belladonna") @db.Json
kourend_favour Json? @map("kourend_favour") @db.Json
geListings GEListing[]
bingo_participant BingoParticipant[]
Expand Down Expand Up @@ -1013,10 +1012,10 @@ model GETransaction {
total_tax_paid BigInt
buy_listing GEListing @relation("buy_transactions", fields: [buy_listing_id], references: [id])
buy_listing GEListing @relation("buy_transactions", fields: [buy_listing_id], references: [id], onDelete: Cascade)
buy_listing_id Int
sell_listing GEListing @relation("sell_transactions", fields: [sell_listing_id], references: [id])
sell_listing GEListing @relation("sell_transactions", fields: [sell_listing_id], references: [id], onDelete: Cascade)
sell_listing_id Int
@@index([sell_listing_id])
Expand Down
6 changes: 1 addition & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { isObject } from 'e';
import { MahojiClient } from 'mahoji';
import { join } from 'path';

import { botToken, DEV_SERVER_ID, production, SENTRY_DSN, SupportServer } from './config';
import { botToken, DEV_SERVER_ID, SENTRY_DSN, SupportServer } from './config';
import { BLACKLISTED_GUILDS, BLACKLISTED_USERS } from './lib/blacklists';
import { Channel, Events, globalConfig, META_CONSTANTS } from './lib/constants';
import { onMessage } from './lib/events';
Expand All @@ -38,10 +38,6 @@ import { convertMahojiCommandToAbstractCommand } from './mahoji/lib/util';

debugLog(`Starting... Git Hash ${META_CONSTANTS.GIT_HASH}`);

if (!production) {
import('./lib/devHotReload');
}

Chart.register(ChartDataLabels);

if (SENTRY_DSN) {
Expand Down
14 changes: 3 additions & 11 deletions src/lib/MUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { GearSetup, UserFullGearSetup } from './gear/types';
import { handleNewCLItems } from './handleNewCLItems';
import backgroundImages from './minions/data/bankBackgrounds';
import { CombatOptionsEnum } from './minions/data/combatConstants';
import { baseUserKourendFavour, UserKourendFavour } from './minions/data/kourendFavour';
import { defaultFarmingContract } from './minions/farming';
import { FarmingContract } from './minions/farming/types';
import { AttackStyles } from './minions/functions';
Expand All @@ -35,7 +34,7 @@ import { SkillsEnum } from './skilling/types';
import { BankSortMethod } from './sorts';
import { defaultGear, Gear } from './structures/Gear';
import { ItemBank, Skills } from './types';
import { addItemToBank, assert, convertXPtoLVL, itemNameFromID, percentChance } from './util';
import { addItemToBank, convertXPtoLVL, itemNameFromID, percentChance } from './util';
import { determineRunes } from './util/determineRunes';
import { getKCByName } from './util/getKCByName';
import getOSItem, { getItem } from './util/getOSItem';
Expand Down Expand Up @@ -163,13 +162,6 @@ export class MUserClass {
});
}

get kourendFavour() {
const favour = this.user.kourend_favour as any as UserKourendFavour | null;
if (favour === null) return { ...baseUserKourendFavour };
assert(typeof favour.Arceuus === 'number', `kourendFavour should return valid data for ${this.id}`);
return favour;
}

get isBusy() {
return userIsBusy(this.id);
}
Expand Down Expand Up @@ -277,7 +269,7 @@ export class MUserClass {

async calcActualClues() {
const result: { id: number; qty: number }[] =
await prisma.$queryRawUnsafe(`SELECT (data->>'clueID')::int AS id, SUM((data->>'quantity')::int) AS qty
await prisma.$queryRawUnsafe(`SELECT (data->>'clueID')::int AS id, SUM((data->>'quantity')::int)::int AS qty
FROM activity
WHERE type = 'ClueCompletion'
AND user_id = '${this.id}'::bigint
Expand Down Expand Up @@ -699,7 +691,7 @@ GROUP BY data->>'clueID';`);
select: keysToSelect
});

return result as SelectedUserStats<T>;
return result as unknown as SelectedUserStats<T>;
}

get logName() {
Expand Down
Loading

0 comments on commit 55f08ee

Please sign in to comment.