From f567aad10db7888d0cc0b0711afac0365e197aa3 Mon Sep 17 00:00:00 2001 From: Effiti Date: Tue, 14 Mar 2023 18:08:27 +0100 Subject: [PATCH 1/8] feat(attributes): use frequency alongside isCommon --- ...30314160556-convert-frequency-to-number.js | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 migrations/20230314160556-convert-frequency-to-number.js diff --git a/migrations/20230314160556-convert-frequency-to-number.js b/migrations/20230314160556-convert-frequency-to-number.js new file mode 100644 index 00000000..c7449179 --- /dev/null +++ b/migrations/20230314160556-convert-frequency-to-number.js @@ -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': { + $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 }, + }) + )); + }, +}; From 4b06f958ade6f66c4376bd1b86f601fc4e837b7b Mon Sep 17 00:00:00 2001 From: Effiti Date: Wed, 15 Mar 2023 20:51:36 +0100 Subject: [PATCH 2/8] feat(attributes): expose frequency field --- src/shared/constants/WordAttributes.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/shared/constants/WordAttributes.js b/src/shared/constants/WordAttributes.js index 8d5a0692..e7258416 100644 --- a/src/shared/constants/WordAttributes.js +++ b/src/shared/constants/WordAttributes.js @@ -11,6 +11,10 @@ export default { value: 'isCommon', label: 'Is Common', }, + FREQUENCY: { + value: 'frequency', + label: 'Frequency', + }, IS_COMPLETE: { value: 'isComplete', label: 'Is Complete', From b07997715b80454118c184631c07b43e5d059c8f Mon Sep 17 00:00:00 2001 From: Effiti Date: Thu, 16 Mar 2023 19:28:51 +0100 Subject: [PATCH 3/8] fix: use frequency field --- migrations/20230314160556-convert-frequency-to-number.js | 4 ++-- src/shared/constants/WordAttributes.js | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/migrations/20230314160556-convert-frequency-to-number.js b/migrations/20230314160556-convert-frequency-to-number.js index c7449179..25c493ce 100644 --- a/migrations/20230314160556-convert-frequency-to-number.js +++ b/migrations/20230314160556-convert-frequency-to-number.js @@ -7,7 +7,7 @@ module.exports = { }, { $addFields: { - 'attributes.frequency': { + frequency: { $cond: { if: { $eq: ['$attributes.isCommon', true], @@ -25,7 +25,7 @@ module.exports = { const collections = ['words', 'wordsuggestions']; return collections.map((collection) => ( db.collection(collection).updateMany({}, { - $unset: { 'attributes.frequency': null }, + $set: { frequency: 0 }, }) )); }, diff --git a/src/shared/constants/WordAttributes.js b/src/shared/constants/WordAttributes.js index e7258416..8d5a0692 100644 --- a/src/shared/constants/WordAttributes.js +++ b/src/shared/constants/WordAttributes.js @@ -11,10 +11,6 @@ export default { value: 'isCommon', label: 'Is Common', }, - FREQUENCY: { - value: 'frequency', - label: 'Frequency', - }, IS_COMPLETE: { value: 'isComplete', label: 'Is Complete', From dfaa0ca53feeaecbbe97af7b36226c599913cd7c Mon Sep 17 00:00:00 2001 From: Effiti Date: Sat, 18 Mar 2023 12:36:49 +0100 Subject: [PATCH 4/8] fix(migrations): use proper migration pipeline --- ...30314160556-convert-frequency-to-number.js | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/migrations/20230314160556-convert-frequency-to-number.js b/migrations/20230314160556-convert-frequency-to-number.js index 25c493ce..42b15e50 100644 --- a/migrations/20230314160556-convert-frequency-to-number.js +++ b/migrations/20230314160556-convert-frequency-to-number.js @@ -5,19 +5,21 @@ module.exports = { db.collection(collection).updateMany({ 'attributes.isCommon': true, }, - { - $addFields: { - frequency: { - $cond: { - if: { - $eq: ['$attributes.isCommon', true], + [ + { + $addFields: { + frequency: { + $cond: { + if: { + $eq: ['$attributes.isCommon', true], + }, + then: 5, + else: 1, }, - then: 5, - else: 1, }, }, }, - }) + ]) )); }, From d41755e21fdcdc45f5445983573ec771f9642675 Mon Sep 17 00:00:00 2001 From: Effiti <48206628+Effiti@users.noreply.github.com> Date: Fri, 24 Mar 2023 15:58:45 +0000 Subject: [PATCH 5/8] Update 20230314160556-convert-frequency-to-number.js --- migrations/20230314160556-convert-frequency-to-number.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/migrations/20230314160556-convert-frequency-to-number.js b/migrations/20230314160556-convert-frequency-to-number.js index 42b15e50..07177562 100644 --- a/migrations/20230314160556-convert-frequency-to-number.js +++ b/migrations/20230314160556-convert-frequency-to-number.js @@ -2,9 +2,7 @@ module.exports = { async up(db) { const collections = ['words', 'wordsuggestions']; return collections.map((collection) => ( - db.collection(collection).updateMany({ - 'attributes.isCommon': true, - }, + db.collection(collection).updateMany({}, [ { $addFields: { From faee30bb1f368e74e19c6e4ebe810fbe5d600468 Mon Sep 17 00:00:00 2001 From: Effiti Date: Fri, 24 Mar 2023 17:28:53 +0100 Subject: [PATCH 6/8] fix(readme): add missing space in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1134a75e..47fc374c 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ 🔎 Full-text search with diacritic support -🚀[Try out a demo here](https://igboapi.com) +🚀 [Try out a demo here](https://igboapi.com) ## Getting Started From b74810e353538c1d62abf5ebf5dc97cb29c41e61 Mon Sep 17 00:00:00 2001 From: Effiti Date: Sat, 25 Mar 2023 17:25:00 +0100 Subject: [PATCH 7/8] fix(readme): add missing empty line in README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 47fc374c..7e966e11 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,7 @@ be ran for testing or specific-feature development purposes. **Reminder**: You must have Redis installed on your machine in order to run the server. ### Docker + If you don't want to run a local Node and MongoDB, you can use [Docker](https://docker.com) Run the following command: From bc7d8d2bc2af29c203d705a165197c175e3e9a2e Mon Sep 17 00:00:00 2001 From: Effiti Date: Sat, 25 Mar 2023 17:50:45 +0100 Subject: [PATCH 8/8] fix(readme): remove unecessary empty line in README --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 7e966e11..45a2425b 100644 --- a/README.md +++ b/README.md @@ -159,7 +159,6 @@ yarn migrate-up Frontend tests focus specifically on the Igbo API homepage using Cypress. First, run: - ``` yarn build ```