resolving pr concerns

This commit is contained in:
Wyatt Johnson
2018-01-05 11:12:35 -07:00
parent 9c595b7f84
commit b42cce5747
3 changed files with 6 additions and 8 deletions
+2 -3
View File
@@ -1,7 +1,6 @@
const DataLoader = require('dataloader');
const util = require('./util');
const sc = require('snake-case');
const {
SEARCH_OTHER_USERS,
@@ -121,7 +120,7 @@ const getUsersByQuery = async ({user}, {limit, cursor, value = '', state, action
if (action_type) {
query.merge({
[`action_counts.${sc(action_type.toLowerCase())}`]: {
[`action_counts.${action_type.toLowerCase()}`]: {
$gt: 0
}
});
@@ -199,7 +198,7 @@ const getCountByQuery = async ({user}, {action_type, state}) => {
if (action_type) {
query.merge({
[`action_counts.${sc(action_type.toLowerCase())}`]: {
[`action_counts.${action_type.toLowerCase()}`]: {
$gt: 0
}
});
@@ -57,7 +57,7 @@ module.exports = {
hooks: {
RootMutation: {
addTag: {
async post(obj, {tag: {name, id, item_type}}, {user, mutators: {Comment}, pubsub}, _info) {
async post(obj, {tag: {name, id, item_type}}, {user, mutators: {Comment}, pubsub}) {
if (name === 'FEATURED' && item_type === 'COMMENTS') {
const comment = await Comment.setStatus({id: id, status: 'ACCEPTED'});
if (comment) {
@@ -67,7 +67,7 @@ module.exports = {
},
},
removeTag: {
async post(obj, {tag: {name, id, item_type}}, {user, loaders: {Comments}, pubsub}, _info) {
async post(obj, {tag: {name, id, item_type}}, {user, loaders: {Comments}, pubsub}) {
if (name === 'FEATURED' && item_type === 'COMMENTS') {
const comment = await Comments.get.load(id);
if (comment) {
+2 -3
View File
@@ -1,7 +1,6 @@
const ActionModel = require('../models/action');
const CommentModel = require('../models/comment');
const UserModel = require('../models/user');
const sc = require('snake-case');
const _ = require('lodash');
const errors = require('../errors');
const events = require('./events');
@@ -253,14 +252,14 @@ module.exports = class ActionsService {
};
const incrActionCounts = async (action, value) => {
const ACTION_TYPE = sc(action.action_type.toLowerCase());
const ACTION_TYPE = action.action_type.toLowerCase();
const update = {
[`action_counts.${ACTION_TYPE}`]: value,
};
if (action.group_id && action.group_id.length > 0) {
const GROUP_ID = sc(action.group_id.toLowerCase());
const GROUP_ID = action.group_id.toLowerCase();
update[`action_counts.${ACTION_TYPE}_${GROUP_ID}`] = value;
}