Merge branch 'master' into gdpr-delete

This commit is contained in:
Wyatt Johnson
2018-05-02 09:58:04 -06:00
59 changed files with 653 additions and 214 deletions
+2
View File
@@ -28,5 +28,7 @@ export {
withRequestAccountDeletion,
withRequestDownloadLink,
withCancelAccountDeletion,
withChangePassword,
withChangeUsername,
} from 'coral-framework/graphql/mutations';
export { compose } from 'recompose';
+15 -11
View File
@@ -2,11 +2,26 @@ const { SEARCH_OTHER_USERS } = require('../../../perms/constants');
const { ErrNotFound, ErrAlreadyExists } = require('../../../errors');
const pluralize = require('pluralize');
const sc = require('snake-case');
const { CREATE_MONGO_INDEXES } = require('../../../config');
const Comment = require('models/comment');
function getReactionConfig(reaction) {
// Ensure that the reaction is a lowercase string.
reaction = reaction.toLowerCase();
if (CREATE_MONGO_INDEXES) {
// Create the index on the comment model based on the reaction config.
Comment.collection.createIndex(
{
created_at: 1,
[`action_counts.${sc(reaction)}`]: 1,
},
{
background: true,
}
);
}
const reactionPlural = pluralize(reaction);
const Reaction = reaction.charAt(0).toUpperCase() + reaction.slice(1);
const REACTION = reaction.toUpperCase();
@@ -114,17 +129,6 @@ function getReactionConfig(reaction) {
return {
typeDefs,
indexes: ({ Comment }) => {
Comment.index(
{
created_at: 1,
[`action_counts.${sc(reaction)}`]: 1,
},
{
background: true,
}
);
},
context: {
Sort: () => ({
Comments: {