perf: Remove collaborators from documents.list response (#2039)
* fix: Remove unused, unperformant query * lint * collaborators -> collaboratorIds
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
// @flow
|
||||
import { takeRight } from "lodash";
|
||||
import { Attachment, Document, User } from "../models";
|
||||
import { Attachment, Document } from "../models";
|
||||
import parseAttachmentIds from "../utils/parseAttachmentIds";
|
||||
import { getSignedImageUrl } from "../utils/s3";
|
||||
import presentUser from "./user";
|
||||
@ -53,7 +52,7 @@ export default async function present(document: Document, options: ?Options) {
|
||||
teamId: document.teamId,
|
||||
template: document.template,
|
||||
templateId: document.templateId,
|
||||
collaborators: [],
|
||||
collaboratorIds: [],
|
||||
starred: document.starred ? !!document.starred.length : undefined,
|
||||
revision: document.revisionCount,
|
||||
pinned: undefined,
|
||||
@ -72,15 +71,7 @@ export default async function present(document: Document, options: ?Options) {
|
||||
data.parentDocumentId = document.parentDocumentId;
|
||||
data.createdBy = presentUser(document.createdBy);
|
||||
data.updatedBy = presentUser(document.updatedBy);
|
||||
|
||||
// TODO: This could be further optimized
|
||||
data.collaborators = (
|
||||
await User.findAll({
|
||||
where: {
|
||||
id: takeRight(document.collaboratorIds, 10) || [],
|
||||
},
|
||||
})
|
||||
).map(presentUser);
|
||||
data.collaboratorIds = document.collaboratorIds;
|
||||
}
|
||||
|
||||
return data;
|
||||
|
Reference in New Issue
Block a user