mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-09 15:15:58 +08:00
allowing disk use for leaderboard aggregation
This commit is contained in:
parent
738ddce0af
commit
447ab9dfc4
1 changed files with 33 additions and 30 deletions
|
@ -34,41 +34,44 @@ class LeaderboardsDAO {
|
|||
let start1 = performance.now();
|
||||
let lb = await mongoDB()
|
||||
.collection("users")
|
||||
.aggregate([
|
||||
{
|
||||
$match: {
|
||||
[str + ".wpm"]: {
|
||||
$exists: true,
|
||||
.aggregate(
|
||||
[
|
||||
{
|
||||
$match: {
|
||||
[str + ".wpm"]: {
|
||||
$exists: true,
|
||||
},
|
||||
[str + ".acc"]: {
|
||||
$exists: true,
|
||||
},
|
||||
[str + ".timestamp"]: {
|
||||
$exists: true,
|
||||
},
|
||||
banned: { $exists: false },
|
||||
},
|
||||
[str + ".acc"]: {
|
||||
$exists: true,
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
[str + ".uid"]: "$uid",
|
||||
[str + ".name"]: "$name",
|
||||
[str + ".discordId"]: "$discordId",
|
||||
},
|
||||
[str + ".timestamp"]: {
|
||||
$exists: true,
|
||||
},
|
||||
{
|
||||
$replaceRoot: {
|
||||
newRoot: "$" + str,
|
||||
},
|
||||
banned: { $exists: false },
|
||||
},
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
[str + ".uid"]: "$uid",
|
||||
[str + ".name"]: "$name",
|
||||
[str + ".discordId"]: "$discordId",
|
||||
{
|
||||
$sort: {
|
||||
wpm: -1,
|
||||
acc: -1,
|
||||
timestamp: -1,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$replaceRoot: {
|
||||
newRoot: "$" + str,
|
||||
},
|
||||
},
|
||||
{
|
||||
$sort: {
|
||||
wpm: -1,
|
||||
acc: -1,
|
||||
timestamp: -1,
|
||||
},
|
||||
},
|
||||
])
|
||||
],
|
||||
{ allowDiskUse: true }
|
||||
)
|
||||
.toArray();
|
||||
let end1 = performance.now();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue