Incorporate limit

This commit is contained in:
Tom Moor 2017-07-06 22:17:37 -07:00
parent b854c2ca53
commit c618b956d2
No known key found for this signature in database
GPG Key ID: 495FE29B5F21BD41
2 changed files with 4 additions and 4 deletions

View File

@ -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) => {

View File

@ -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));
}