Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(attributes): use frequency alongside isCommon #576

Merged
merged 9 commits into from
Mar 27, 2023
32 changes: 32 additions & 0 deletions migrations/20230314160556-convert-frequency-to-number.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module.exports = {
async up(db) {
const collections = ['words', 'wordsuggestions'];
return collections.map((collection) => (
db.collection(collection).updateMany({
'attributes.isCommon': true,
},
{
$addFields: {
'attributes.frequency': {
Effiti marked this conversation as resolved.
Show resolved Hide resolved
$cond: {
if: {
$eq: ['$attributes.isCommon', true],
},
then: 5,
else: 1,
},
},
},
})
));
},

async down(db) {
const collections = ['words', 'wordsuggestions'];
return collections.map((collection) => (
db.collection(collection).updateMany({}, {
$unset: { 'attributes.frequency': null },
Effiti marked this conversation as resolved.
Show resolved Hide resolved
})
));
},
};
4 changes: 4 additions & 0 deletions src/shared/constants/WordAttributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ export default {
value: 'isCommon',
label: 'Is Common',
},
FREQUENCY: {
value: 'frequency',
label: 'Frequency',
},
Effiti marked this conversation as resolved.
Show resolved Hide resolved
IS_COMPLETE: {
value: 'isComplete',
label: 'Is Complete',
Expand Down