From 864fb090d8180100cce27d708e6de569e848fe33 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 fd37840ff..f233de25a 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 9440e2b3a..387ed3bea 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 3745a92e0..818c63694 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 0428b400b..9bc25315a 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 a118ca6fb..ed97a601e 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 1c6024e3e..671eaae14 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) };