Initial commit

This commit is contained in:
2026-08-24 22:20:36 +02:00
commit 62f7b1278a
251 changed files with 16670 additions and 0 deletions
+49
View File
@@ -0,0 +1,49 @@
const leaderboards = require("../Data/leaderboard");
const BATCH_SIZE = 1000;
const INTERVAL_TIME = 10000;
const playerBehaviourContext = global.playerBehaviourContext;
let mongoBehaviourCollection = null;
let mongoDB = null;
const { MongoClient } = require("mongodb");
async function connect() {
const client = new MongoClient("mongodb://localhost:27017");
await client.connect({
maxPoolSize: 100,
minPoolSize: 20,
maxConnecting: 20,
waitQueueTimeoutMS: 0,
socketTimeoutMS: 30000,
connectTimeoutMS: 10000,
retryWrites: false,
directConnection: true
});
return client.db("test");
};
(async function() {
mongoDB = await connect();
mongoBehaviourCollection = mongoDB.collection("Behaviour");
})();
async function behaviourLoop() {
if (playerBehaviourContext.length === 0) return;
//require("../Miscellaneous/winston").error(playerBehaviourContext);
// console.info(playerBehaviourContext, "loop");
const playerBehaviourContextCopy = playerBehaviourContext.slice();
mongoBehaviourCollection.insertMany(playerBehaviourContextCopy, {
ordered: false,
writeConcern: { w: 0 },
bypassDocumentValidation: true
});
playerBehaviourContext.length = 0;
};
setInterval(behaviourLoop, INTERVAL_TIME);
module.exports = behaviourLoop;