Compare commits
1 Commits
4e3823473f
...
b8109d0bc4
Author | SHA1 | Date | |
---|---|---|---|
b8109d0bc4 |
@ -40,18 +40,20 @@ export const getLeaderboard = async (
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
const beforeDocs = await Leaderboard.find({
|
const beforeDocs = await Leaderboard.find({
|
||||||
|
leaderboard,
|
||||||
score: { $gt: pivotDoc.score }
|
score: { $gt: pivotDoc.score }
|
||||||
})
|
})
|
||||||
.sort({ score: 1 })
|
.sort({ score: 1 })
|
||||||
.limit(before);
|
.limit(before);
|
||||||
const afterDocs = await Leaderboard.find({
|
const afterDocs = await Leaderboard.find({
|
||||||
|
leaderboard,
|
||||||
score: { $lt: pivotDoc.score }
|
score: { $lt: pivotDoc.score }
|
||||||
})
|
})
|
||||||
.sort({ score: -1 })
|
.sort({ score: -1 })
|
||||||
.limit(after);
|
.limit(after);
|
||||||
entries = [...beforeDocs.reverse(), pivotDoc, ...afterDocs];
|
entries = [...beforeDocs.reverse(), pivotDoc, ...afterDocs];
|
||||||
r = await Leaderboard.countDocuments({
|
r = await Leaderboard.countDocuments({
|
||||||
leaderboard: leaderboard,
|
leaderboard,
|
||||||
score: { $gt: pivotDoc.score }
|
score: { $gt: pivotDoc.score }
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user