diff --git a/server/middlewares/cache.js b/server/middlewares/cache.js index 7a10ad64..22068f62 100644 --- a/server/middlewares/cache.js +++ b/server/middlewares/cache.js @@ -1,9 +1,10 @@ +// @flow import debug from 'debug'; const debugCache = debug('cache'); export default function cache() { - return async function cacheMiddleware(ctx, next) { + return async function cacheMiddleware(ctx: Object, next: Function) { ctx.cache = {}; ctx.cache.set = async (id, value) => { diff --git a/server/presenters/document.js b/server/presenters/document.js index 80db7f53..e89658a5 100644 --- a/server/presenters/document.js +++ b/server/presenters/document.js @@ -1,4 +1,5 @@ // @flow +import _ from 'lodash'; import { User, Document, View } from '../models'; import presentUser from './user'; import presentCollection from './collection'; @@ -43,9 +44,7 @@ async function present(ctx: Object, document: Document, options: Object = {}) { // This could be further optimized by using ctx.cache data.collaborators = await User.findAll({ where: { - id: { - $in: document.collaboratorIds || [], - }, + id: { $in: _.takeRight(document.collaboratorIds, 10) || [] }, }, }).map(user => presentUser(ctx, user)); }