Compare commits
5 Commits
46efd6b6dc
...
renovate/d
Author | SHA1 | Date | |
---|---|---|---|
c5d78c502b | |||
f621f6c5ae | |||
3621941a0d | |||
fe15f660e6 | |||
5c2416e7ee |
8
package-lock.json
generated
8
package-lock.json
generated
@ -545,14 +545,14 @@
|
||||
}
|
||||
},
|
||||
"node_modules/dotenv": {
|
||||
"version": "16.3.1",
|
||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz",
|
||||
"integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==",
|
||||
"version": "16.4.5",
|
||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz",
|
||||
"integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/motdotla/dotenv?sponsor=1"
|
||||
"url": "https://dotenvx.com"
|
||||
}
|
||||
},
|
||||
"node_modules/ee-first": {
|
||||
|
@ -6,6 +6,7 @@
|
||||
"scripts": {
|
||||
"start": "node dist/index.js",
|
||||
"tsc": "tsc -w",
|
||||
"build": "tsc",
|
||||
"dev": "nodemon dist/index.js"
|
||||
},
|
||||
"author": "",
|
||||
|
1446
pnpm-lock.yaml
generated
1446
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -13,6 +13,7 @@ let totalDeleted: number | undefined;
|
||||
|
||||
// Thee last time a map was heard
|
||||
let lastMap: number = Date.now();
|
||||
let socket: WebsocketClient | undefined;
|
||||
|
||||
async function update() {
|
||||
if (totalCreated == undefined) {
|
||||
@ -45,7 +46,7 @@ async function update() {
|
||||
}
|
||||
|
||||
async function connectWebsocket() {
|
||||
const socket = new WebsocketClient(WEBSOCKET_URL);
|
||||
socket = new WebsocketClient(WEBSOCKET_URL);
|
||||
await connectMongo();
|
||||
let beatSaver = await BeatSaverSchema.findOne({ _id: "beatsaver" });
|
||||
if (!beatSaver) {
|
||||
@ -129,8 +130,10 @@ async function connectWebsocket() {
|
||||
connectWebsocket();
|
||||
cron.schedule("*/5 * * * *", update);
|
||||
cron.schedule("*/1 * * * *", () => {
|
||||
if (lastMap && Date.now() - lastMap > 10000) {
|
||||
// 1 minute
|
||||
if (lastMap && Date.now() - lastMap > 60_000) {
|
||||
console.log("Beatsaver websocket is dead, reconnecting");
|
||||
socket?.close();
|
||||
connectWebsocket();
|
||||
}
|
||||
});
|
||||
|
@ -12,6 +12,7 @@ let totalScores: number | undefined;
|
||||
|
||||
// Thee last time a score was heard
|
||||
let lastScore: number = Date.now();
|
||||
let socket: WebsocketClient | undefined;
|
||||
|
||||
/**
|
||||
* Updates the player count and adds data to influx
|
||||
@ -50,7 +51,7 @@ async function connectWebsocket() {
|
||||
// set total scores to the current total plays in the database
|
||||
totalScores = leaderboard?.totalPlays || 0;
|
||||
|
||||
const socket = new WebsocketClient("wss://scoresaber.com/ws");
|
||||
socket = new WebsocketClient("wss://scoresaber.com/ws");
|
||||
socket.onopen = () => {
|
||||
console.log("Connected to scoresaber websocket");
|
||||
};
|
||||
@ -157,8 +158,10 @@ update();
|
||||
connectWebsocket();
|
||||
cron.schedule("*/1 * * * *", update);
|
||||
cron.schedule("*/1 * * * *", () => {
|
||||
if (lastScore && Date.now() - lastScore > 10000) {
|
||||
// 1 minute
|
||||
if (lastScore && Date.now() - lastScore > 60_000) {
|
||||
console.log("Scoresaber websocket is dead, reconnecting");
|
||||
socket?.close();
|
||||
connectWebsocket();
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user