From b82eda5046119213e2a4adb8a46babd61bde50f8 Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 23 Jan 2017 14:53:46 +0900 Subject: [PATCH] [Server] Fix query performance --- src/api/endpoints/drive/folders.js | 4 ++-- src/api/endpoints/messaging/messages.js | 4 ++-- src/api/endpoints/my/apps.js | 2 +- src/api/endpoints/posts.js | 4 ++-- src/api/endpoints/posts/reposts.js | 4 ++-- src/api/endpoints/users.js | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/api/endpoints/drive/folders.js b/src/api/endpoints/drive/folders.js index fd37840ff7..f233de25a1 100644 --- a/src/api/endpoints/drive/folders.js +++ b/src/api/endpoints/drive/folders.js @@ -49,14 +49,14 @@ module.exports = (params, user, app) => // Construct query const sort = { - created_at: -1 + _id: -1 }; const query = { user_id: user._id, parent_id: folder }; if (since !== null) { - sort.created_at = 1; + sort._id = 1; query._id = { $gt: new mongo.ObjectID(since) }; diff --git a/src/api/endpoints/messaging/messages.js b/src/api/endpoints/messaging/messages.js index 9440e2b3aa..387ed3bea1 100644 --- a/src/api/endpoints/messaging/messages.js +++ b/src/api/endpoints/messaging/messages.js @@ -74,11 +74,11 @@ module.exports = (params, user) => }; const sort = { - created_at: -1 + _id: -1 }; if (since !== null) { - sort.created_at = 1; + sort._id = 1; query._id = { $gt: new mongo.ObjectID(since) }; diff --git a/src/api/endpoints/my/apps.js b/src/api/endpoints/my/apps.js index 3745a92e0f..818c636949 100644 --- a/src/api/endpoints/my/apps.js +++ b/src/api/endpoints/my/apps.js @@ -48,7 +48,7 @@ module.exports = (params, user) => limit: limit, skip: offset, sort: { - created_at: -1 + _id: -1 } }); diff --git a/src/api/endpoints/posts.js b/src/api/endpoints/posts.js index 0428b400bc..9bc25315a7 100644 --- a/src/api/endpoints/posts.js +++ b/src/api/endpoints/posts.js @@ -38,11 +38,11 @@ module.exports = (params) => // Construct query const sort = { - created_at: -1 + _id: -1 }; const query = {}; if (since !== null) { - sort.created_at = 1; + sort._id = 1; query._id = { $gt: new mongo.ObjectID(since) }; diff --git a/src/api/endpoints/posts/reposts.js b/src/api/endpoints/posts/reposts.js index a118ca6fba..ed97a601e3 100644 --- a/src/api/endpoints/posts/reposts.js +++ b/src/api/endpoints/posts/reposts.js @@ -55,13 +55,13 @@ module.exports = (params, user) => // Construct query const sort = { - created_at: -1 + _id: -1 }; const query = { repost_id: post._id }; if (since !== null) { - sort.created_at = 1; + sort._id = 1; query._id = { $gt: new mongo.ObjectID(since) }; diff --git a/src/api/endpoints/users.js b/src/api/endpoints/users.js index 1c6024e3ee..671eaae14f 100644 --- a/src/api/endpoints/users.js +++ b/src/api/endpoints/users.js @@ -39,11 +39,11 @@ module.exports = (params, me) => // Construct query const sort = { - created_at: -1 + _id: -1 }; const query = {}; if (since !== null) { - sort.created_at = 1; + sort._id = 1; query._id = { $gt: new mongo.ObjectID(since) };