update
This commit is contained in:
parent
787c112f15
commit
d522537423
7 changed files with 45 additions and 12 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -4,3 +4,4 @@ node_modules
|
||||||
.venv
|
.venv
|
||||||
|
|
||||||
prisma/dev.db*
|
prisma/dev.db*
|
||||||
|
logs.txt
|
||||||
|
|
BIN
bun.lockb
BIN
bun.lockb
Binary file not shown.
17
main.ts
17
main.ts
|
@ -2,7 +2,7 @@ import "dotenv/config";
|
||||||
import Datastore from "nedb";
|
import Datastore from "nedb";
|
||||||
import WebSocket from "ws";
|
import WebSocket from "ws";
|
||||||
import { createInterface } from "readline";
|
import { createInterface } from "readline";
|
||||||
import { Channel, Client, Score } from "osu-web.js";
|
import { Client, type Channel, type Score } from "osu-web.js";
|
||||||
import { PrismaClient } from "@prisma/client";
|
import { PrismaClient } from "@prisma/client";
|
||||||
const prisma = new PrismaClient();
|
const prisma = new PrismaClient();
|
||||||
|
|
||||||
|
@ -196,9 +196,14 @@ async function scrapeChannels() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getStats(elapsed) {
|
async function getStats(elapsed) {
|
||||||
|
// console.clear();
|
||||||
|
|
||||||
const result = await prisma.score.count();
|
const result = await prisma.score.count();
|
||||||
|
const users = (await prisma.score.groupBy({ by: ["user_id"] })).length;
|
||||||
console.log(
|
console.log(
|
||||||
`${result} total scores (prev query: ${Math.round(elapsed / 10) / 100}s)`,
|
`${result} total scores, ${users} total users, (prev query: ${
|
||||||
|
Math.round(elapsed / 10) / 100
|
||||||
|
}s)`,
|
||||||
);
|
);
|
||||||
|
|
||||||
const result2 = await prisma.$queryRaw`
|
const result2 = await prisma.$queryRaw`
|
||||||
|
@ -215,14 +220,10 @@ async function getStats(elapsed) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function mainLoop() {
|
while (true) {
|
||||||
while (true) {
|
|
||||||
const start = performance.now();
|
const start = performance.now();
|
||||||
await scrapeChannels();
|
await scrapeChannels();
|
||||||
const end = performance.now();
|
const end = performance.now();
|
||||||
await getStats(end - start);
|
await getStats(end - start);
|
||||||
await sleep(10000);
|
await Bun.sleep(10000);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mainLoop();
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
"osu-web.js": "^2.4.0"
|
"osu-web.js": "^2.4.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/bun": "^1.1.3",
|
||||||
"@types/nedb": "^1.8.16",
|
"@types/nedb": "^1.8.16",
|
||||||
"@types/ws": "^8.5.10",
|
"@types/ws": "^8.5.10",
|
||||||
"prisma": "^5.14.0"
|
"prisma": "^5.14.0"
|
||||||
|
|
5
prisma/migrations/20240530173352_a/migration.sql
Normal file
5
prisma/migrations/20240530173352_a/migration.sql
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE INDEX "Score_user_id_idx" ON "Score"("user_id");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE INDEX "Transition_user_id_idx" ON "Transition"("user_id");
|
|
@ -49,6 +49,7 @@ model Score {
|
||||||
transition_to Transition[] @relation("after")
|
transition_to Transition[] @relation("after")
|
||||||
|
|
||||||
@@unique([user_id, beatmap_id, created_at, score])
|
@@unique([user_id, beatmap_id, created_at, score])
|
||||||
|
@@index([user_id])
|
||||||
}
|
}
|
||||||
|
|
||||||
model Transition {
|
model Transition {
|
||||||
|
@ -61,4 +62,5 @@ model Transition {
|
||||||
ms_between BigInt
|
ms_between BigInt
|
||||||
|
|
||||||
@@id([before_id, after_id])
|
@@id([before_id, after_id])
|
||||||
|
@@index([user_id])
|
||||||
}
|
}
|
||||||
|
|
23
tsconfig.json
Normal file
23
tsconfig.json
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"lib": ["ESNext", "DOM"],
|
||||||
|
"target": "ESNext",
|
||||||
|
"module": "ESNext",
|
||||||
|
"moduleDetection": "force",
|
||||||
|
"jsx": "react-jsx",
|
||||||
|
"allowJs": true,
|
||||||
|
|
||||||
|
"moduleResolution": "bundler",
|
||||||
|
"allowImportingTsExtensions": true,
|
||||||
|
"verbatimModuleSyntax": true,
|
||||||
|
"noEmit": true,
|
||||||
|
|
||||||
|
"strict": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"noFallthroughCasesInSwitch": true,
|
||||||
|
|
||||||
|
"noUnusedLocals": true,
|
||||||
|
"noUnusedParameters": true,
|
||||||
|
"noPropertyAccessFromIndexSignature": true
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue