This commit is contained in:
Belen Curcio
2017-01-24 18:21:49 -03:00
38 changed files with 89 additions and 110 deletions
-8
View File
@@ -44,16 +44,8 @@ const getCommentsByStatusAndAssetID = (context, {status = null, asset_id = null}
};
const getCommentsByActionTypeAndAssetID = (context, {action_type, asset_id = null}) => {
// TODO: remove when we move the enum over to the uppercase.
if (action_type) {
action_type = action_type.toLowerCase();
}
return ActionModel.find({
action_type,
// TODO: remove when we move the enum over to the uppercase.
item_type: 'COMMENTS'
}).then((actions) => {
let comments = CommentModel.find({
+5 -1
View File
@@ -1,8 +1,12 @@
const DataLoader = require('dataloader');
const util = require('./util');
const UsersService = require('../../services/users');
const genUserByIDs = (context, ids) => UsersService.findByIdArray(ids);
const genUserByIDs = (context, ids) => UsersService
.findByIdArray(ids)
.then(util.singleJoinBy(ids, 'id'));
/**
* Creates a set of loaders based on a GraphQL context.
+1 -13
View File
@@ -1,21 +1,9 @@
const Action = {
action_type({action_type}) {
// FIXME: remove once we cast the data model to have uppercase action
// types.
return action_type.toUpperCase();
},
item_type({item_type}) {
// FIXME: remove once we cast the data model to have uppercase item
// types.
return item_type.toUpperCase();
},
// This will load the user for the specific action. We'll limit this to the
// admin users only.
user({user_id}, _, {loaders, user}) {
if (user.hasRole('admin')) {
if (user.hasRole('ADMIN')) {
return loaders.Users.getByID.load(user_id);
}
}
+1 -14
View File
@@ -1,16 +1,3 @@
const ActionSummary = {
action_type({action_type}) {
// FIXME: remove once we cast the data model to have uppercase action
// types.
return action_type.toUpperCase();
},
item_type({item_type}) {
// FIXME: remove once we cast the data model to have uppercase item
// types.
return item_type.toUpperCase();
}
};
const ActionSummary = {};
module.exports = ActionSummary;
-7
View File
@@ -8,13 +8,6 @@ const Comment = {
actions({id}, _, {loaders}) {
return loaders.Actions.getByItemID.load(id);
},
status({status}) {
// Because the status can be `null`, we do this check.
if (status) {
return status.toUpperCase();
}
},
asset({asset_id}, _, {loaders}) {
return loaders.Assets.getByID.load(asset_id);
}
+2 -2
View File
@@ -1,6 +1,6 @@
const RootQuery = {
assets(_, args, {loaders, user}) {
if (user == null || !user.hasRoles('admin')) {
if (user == null || !user.hasRoles('ADMIN')) {
return null;
}
@@ -25,7 +25,7 @@ const RootQuery = {
// This endpoint is used for loading moderation queues, so hide it in the
// event that we aren't an admin.
comments(_, {query}, {loaders, user}) {
if (user == null || !user.hasRoles('admin')) {
if (user == null || !user.hasRoles('ADMIN')) {
return null;
}
+1 -1
View File
@@ -6,7 +6,7 @@ const User = {
// If the user is not an admin, only return comment list for the owner of
// the comments.
if (!user.hasRoles('admin') || user.id !== id) {
if (!user.hasRoles('ADMIN') || user.id !== id) {
return null;
}