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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -158,7 +159,6 @@ yarn migrate-up

Frontend tests focus specifically on the Igbo API homepage using Cypress. First, run:


```
yarn build
```
Expand Down
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({},
[
{
$addFields: {
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({}, {
$set: { frequency: 0 },
})
));
},
};