Removing extra commas and collapsing actions into an object in the backend.

This commit is contained in:
David Jay
2016-12-08 15:27:49 -05:00
parent b3d84d724f
commit 9d28577e9b
7 changed files with 13 additions and 37 deletions
+5 -12
View File
@@ -32,23 +32,16 @@ ActionSchema.statics.findById = function(id) {
/**
* Add an action.
* @param {String} item_id identifier of the comment (uuid)
* @param {String} item_id identifier of the item (uuid)
* @param {String} user_id user id of the action (uuid)
* @param {String} action the new action to the comment
* @param {String} action the new action to the item
* @return {Promise}
*/
ActionSchema.statics.insertUserAction = ({item_id, item_type, user_id, action_type, field, detail}) => {
const action = {
item_id,
item_type,
user_id,
action_type,
field,
detail
};
ActionSchema.statics.insertUserAction = ({item_id, item_type, user_id, action}) => {
let action_obj = Object.assign({}, action, {item_id, item_type, user_id});
// Create/Update the action.
return Action.findOneAndUpdate(action, action, {
return Action.findOneAndUpdate(action_obj, action_obj, {
// Ensure that if it's new, we return the new object created.
new: true,
+2 -4
View File
@@ -284,13 +284,11 @@ CommentSchema.statics.pushStatus = (id, status, assigned_by = null) => Comment.u
* @param {String} action the new action to the comment
* @return {Promise}
*/
CommentSchema.statics.addAction = (item_id, user_id, action_type, field, detail) => Action.insertUserAction({
CommentSchema.statics.addAction = (item_id, user_id, action) => Action.insertUserAction({
item_id,
item_type: 'comment',
user_id,
action_type,
field,
detail
action
});
/**
+2 -4
View File
@@ -555,11 +555,9 @@ UserService.addBio = (id, bio) => (
* @param {String} action the new action to the user
* @return {Promise}
*/
UserService.addAction = (item_id, user_id, action_type, field, detail) => Action.insertUserAction({
UserService.addAction = (item_id, user_id, action) => Action.insertUserAction({
item_id,
item_type: 'comment',
user_id,
action_type,
field,
detail
action
});