Merge branch 'master' into asset-graph-api

This commit is contained in:
Kiwi
2017-08-29 21:04:30 +02:00
committed by GitHub
91 changed files with 1757 additions and 1708 deletions
+4 -4
View File
@@ -43,8 +43,8 @@ const getCountsByAssetID = (context, asset_ids) => {
}
}
])
.then(singleJoinBy(asset_ids, '_id'))
.then((results) => results.map((result) => result ? result.count : 0));
.then(singleJoinBy(asset_ids, '_id'))
.then((results) => results.map((result) => result ? result.count : 0));
};
/**
@@ -76,8 +76,8 @@ const getParentCountsByAssetID = (context, asset_ids) => {
}
}
])
.then(singleJoinBy(asset_ids, '_id'))
.then((results) => results.map((result) => result ? result.count : 0));
.then(singleJoinBy(asset_ids, '_id'))
.then((results) => results.map((result) => result ? result.count : 0));
};
/**
+8 -8
View File
@@ -35,20 +35,20 @@ const getAssetActivityMetrics = ({loaders: {Assets}}, {from, to, limit}) => {
}},
{$limit: limit}
])
.then((results) => {
assetMetrics = results;
.then((results) => {
assetMetrics = results;
return Assets.getByID.loadMany(results.map((result) => result.asset_id));
})
.then((assets) => assets.map((asset, i) => {
return Assets.getByID.loadMany(results.map((result) => result.asset_id));
})
.then((assets) => assets.map((asset, i) => {
// We're leveraging the fact that the comments returned by the aggregation
// query are in the request order that we just made, it's what the
// Assets.getByID loader does.
asset.commentCount = assetMetrics[i].commentCount;
asset.commentCount = assetMetrics[i].commentCount;
return asset;
}));
return asset;
}));
};
/**
+1 -1
View File
@@ -26,7 +26,7 @@ const genUserByIDs = async (context, ids) => {
* @param {Object} context graph context
* @param {Object} query query terms to apply to the users query
*/
const getUsersByQuery = ({user}, {ids, limit, cursor, statuses = null, sortOrder}) => {
const getUsersByQuery = (ctx, {ids, limit, cursor, statuses = null, sortOrder}) => {
let users = UserModel.find();
+1 -1
View File
@@ -5,7 +5,7 @@ const {ADD_COMMENT_TAG, REMOVE_COMMENT_TAG} = require('../../perms/constants');
/**
* Modifies the targeted model with the specified operation to add/remove a tag.
*/
const modify = async ({user, loaders: {Tags}, pubsub}, operation, {name, id, item_type, asset_id}) => {
const modify = async ({user, loaders: {Tags}}, operation, {name, id, item_type, asset_id}) => {
// Get the global list of tags from the dataloader.
const tags = await Tags.getAll.load({id, item_type, asset_id});
+3 -3
View File
@@ -2,7 +2,7 @@ const errors = require('../../errors');
const UsersService = require('../../services/users');
const {SET_USER_STATUS, SUSPEND_USER, REJECT_USERNAME} = require('../../perms/constants');
const setUserStatus = async ({user, pubsub}, {id, status}) => {
const setUserStatus = async ({pubsub}, {id, status}) => {
const result = await UsersService.setStatus(id, status);
if (result && result.status === 'BANNED') {
pubsub.publish('userBanned', result);
@@ -10,7 +10,7 @@ const setUserStatus = async ({user, pubsub}, {id, status}) => {
return result;
};
const suspendUser = async ({user, pubsub}, {id, message, until}) => {
const suspendUser = async ({pubsub}, {id, message, until}) => {
const result = await UsersService.suspendUser(id, message, until);
if (result) {
pubsub.publish('userSuspended', result);
@@ -18,7 +18,7 @@ const suspendUser = async ({user, pubsub}, {id, message, until}) => {
return result;
};
const rejectUsername = async ({user, pubsub}, {id, message}) => {
const rejectUsername = async ({pubsub}, {id, message}) => {
const result = await UsersService.rejectUsername(id, message);
if (result) {
pubsub.publish('usernameRejected', result);