Added more comment sorting

This commit is contained in:
Wyatt Johnson
2017-01-24 17:22:29 -07:00
parent eb469df573
commit 373f119ac2
+10 -6
View File
@@ -62,7 +62,7 @@ const getCommentsByActionTypeAndAssetID = (context, {action_type, asset_id = nul
id: {
$in: actions.map((action) => action.item_id)
}
});
}).sort({created_at: 1});
if (asset_id) {
comments = comments.where({asset_id});
@@ -72,11 +72,15 @@ const getCommentsByActionTypeAndAssetID = (context, {action_type, asset_id = nul
});
};
const genCommentsByAuthorID = (context, authorIDs) => CommentModel.find({
author_id: {
$in: authorIDs
}
}).then(util.arrayJoinBy(authorIDs, 'author_id'));
const genCommentsByAuthorID = (context, authorIDs) => {
return CommentModel.find({
author_id: {
$in: authorIDs
}
})
.sort({created_at: -1})
.then(util.arrayJoinBy(authorIDs, 'author_id'));
};
/**
* Creates a set of loaders based on a GraphQL context.