mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-09-22 00:06:06 +08:00
[client-sync] limit attributes returned for messages
Summary: I did a grep for `Message.find.*` to see if there were any other places we could limit the attributes returned There were. This used to be INSANELY wasteful to return all bodies when we only needed the ids. Test Plan: Manually bootup app and ensure search still works Reviewers: mark, juan, spang Reviewed By: mark, juan, spang Differential Revision: https://phab.nylas.com/D4042
This commit is contained in:
parent
c7bdb5804a
commit
f23a96c481
|
@ -147,6 +147,7 @@ class GmailSearchClient {
|
|||
|
||||
const {Message} = db;
|
||||
const messages = await Message.findAll({
|
||||
attributes: ['id', 'threadId'],
|
||||
where: {gMsgId: {$in: messageIds}},
|
||||
});
|
||||
|
||||
|
@ -250,6 +251,7 @@ class ImapSearchClient {
|
|||
const {Message} = db;
|
||||
return (await this._search(db, query)).flatMap((uids) => {
|
||||
return Message.findAll({
|
||||
attributes: ['id', 'threadId'],
|
||||
where: {folderImapUID: uids},
|
||||
});
|
||||
}).flatMap((messages) => {
|
||||
|
|
|
@ -103,7 +103,10 @@ class SyncbackTaskRunner {
|
|||
affectedMessageIds.add(messageId)
|
||||
}
|
||||
} else if (threadId) {
|
||||
const messageIds = await Message.findAll({where: {threadId}}).map(m => m.id)
|
||||
const messageIds = await Message.findAll({
|
||||
attributes: ['id', 'threadId'],
|
||||
where: {threadId}})
|
||||
.map(m => m.id)
|
||||
const shouldIncludeTask = messageIds.every(id => !affectedMessageIds.has(id))
|
||||
if (shouldIncludeTask) {
|
||||
tasksToProcess.push(task)
|
||||
|
|
Loading…
Reference in a new issue