Currently, I am sifting through approximately 12,000 users, which amounts to over 1,000 each day. I am using MongoDB with monk and have implemented the following sorting code.
class User {
constructor(doc) {
this.username = doc.username
this.kills = doc.kills;
this.deaths = doc.deaths;
}};
let res = await Calls.getAllUsers()
let users = res.map((doc) => new User(doc));
const sorted = users.sort((a, b) => b.kills - a.kills);
const whereIam = sorted.indexOf(users.find((u) => u.username === user_grab)) + 1;
The variable "whereIam" is causing performance issues, resulting in approximately 20 seconds delay for every query.