Graph fixes and migrations

- Added migrations for mapping old keys
- Added migration for fixing old dont agree flags
- Removed enum requirement for output
This commit is contained in:
Wyatt Johnson
2017-10-10 11:22:19 -06:00
parent d6e7bb0a0a
commit 86c3c286ee
6 changed files with 81 additions and 5 deletions
+2 -2
View File
@@ -267,7 +267,7 @@ const moderationPhases = [
actions: [{
action_type: 'FLAG',
user_id: null,
group_id: 'Matched suspect word filter',
group_id: 'SUSPECT_WORD',
metadata: {}
}],
};
@@ -302,7 +302,7 @@ const moderationPhases = [
// Add the flag related to Trust to the comment.
return {
status:'SYSTEM_WITHHELD',
status: 'SYSTEM_WITHHELD',
actions: [{
action_type: 'FLAG',
user_id: null,
+2 -2
View File
@@ -555,7 +555,7 @@ type FlagAction implements Action {
id: ID!
# The reason for which the Flag Action was created.
reason: FLAG_REASON
reason: String
# An optional message sent with the flagging action by the user.
message: String
@@ -596,7 +596,7 @@ type FlagActionSummary implements ActionSummary {
count: Int!
# The reason for which the Flag Action was created.
reason: FLAG_REASON
reason: String
# The flag by the current user against the parent entity with this reason.
current_user: FlagAction
+5
View File
@@ -263,6 +263,11 @@ en:
comment_spam: "Spam"
comment_noagree: "Disagree"
comment_other: "Other"
suspect_word: "Suspect Word"
banned_word: "Banned Word"
body_count: "Body exceeds max length"
links: "Links"
trust: "Trust"
modqueue:
account: "account flags"
actions: Actions
+50
View File
@@ -0,0 +1,50 @@
const ActionModel = require('../models/action');
const mapping = {
COMMENTS: {
'Comment contains toxic language': 'TOXIC_COMMENT',
'Matched suspect word filter': 'SUSPECT_WORD',
'other': 'COMMENT_OTHER',
'Other': 'COMMENT_OTHER',
'This looks like an ad/marketing': 'COMMENT_SPAM',
'This comment is offensive': 'COMMENT_OFFENSIVE',
},
};
module.exports = {
async up() {
// Setup the batch operation.
const batch = ActionModel.collection.initializeUnorderedBulkOp();
for (const item_type in mapping) {
const mappings = mapping[item_type];
for (const OLD_GROUP_ID in mappings) {
const NEW_GROUP_ID = mappings[OLD_GROUP_ID];
// OLD
// {
// group_id: <OLD_GROUP_ID>
// }
// NEW
// {
// group_id: <NEW_GROUP_ID>
// }
batch.find({
group_id: OLD_GROUP_ID,
item_type,
}).update({
$set: {
group_id: NEW_GROUP_ID,
},
});
}
}
// Execute the batch update operation.
await batch.execute();
}
};
+21
View File
@@ -0,0 +1,21 @@
const ActionModel = require('../models/action');
module.exports = {
async up() {
// This will update all the old flags that are 'COMMENT_NOAGREE' to change
// them to DONTAGREE actions instead.
return ActionModel.update({
action_type: 'FLAG',
group_id: 'COMMENT_NOAGREE',
}, {
$set: {
action_type: 'DONTAGREE',
group_id: null,
},
}, {
multi: true,
});
}
};
+1 -1
View File
@@ -22,7 +22,7 @@
},
"talk": {
"migration": {
"minVersion": 1496771633
"minVersion": 1507322128
}
},
"config": {