mirror of
https://github.com/spacebarchat/server.git
synced 2026-03-30 11:51:18 +00:00
speed up fetching messages
This commit is contained in:
@@ -147,6 +147,7 @@ router.get(
|
||||
if (around) {
|
||||
query.take = Math.floor(limit / 2);
|
||||
if (query.take != 0) {
|
||||
console.time("Query");
|
||||
const [right, left] = await Promise.all([
|
||||
Message.find({
|
||||
...query,
|
||||
@@ -158,6 +159,7 @@ router.get(
|
||||
order: { timestamp: "ASC" },
|
||||
}),
|
||||
]);
|
||||
console.timeEnd("Query");
|
||||
left.push(...right);
|
||||
messages = left.sort((a, b) => a.timestamp.getTime() - b.timestamp.getTime());
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user