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

Assignment Week4 <Ozlem Karaboga> #33

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

OzlemKaraboga
Copy link

No description provided.

@sarlam sarlam self-assigned this Sep 1, 2024
Copy link

@sarlam sarlam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work!

The second aggregation per continent is not working as expected, feel free to ask around


const result = await collection.aggregate([
{
$match: { Year: year, Age: age }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the moment this only aggregate per age and year, it is lacking something to also group per continent

const accountsCollection = database.collection("accounts");

const session = client.startSession();
session.startTransaction();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really good, really easy to read.

Another way of doing the exact same thing would be to use withTransaction I am mentioning it as you might see it in someone else work

@@ -44,11 +45,9 @@ const getContinentInformationByYearAndAge = async (year, age) => {
},
{
$addFields: {
TotalPopulation: { $add: ["$M", "$F"] }
TotalPopulation: { $add: ["$M", "$F"] },
Country: "$Country",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This adds the fields to your result but it does not filter or aggregate per continent.

What we are looking for is something that in the end would have one object per continent year and age, lucky for us, the dataset already have those information, At this point you will need to look into the dataset itself to find if you have some data about continents instead of countries (maybe search for Europe and see what it result on)

I would advise, since the data is stored in mongodb to use the power from mongodb and javascript to figure our what the Country field can be and maybe search into it what could be used to have the data per continents

Comment on lines +45 to +46
{ Country: { $regex: /^[A-Z]+$/ } },
{ Country: { $not: { $regex: /world/i } } }]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will work but I will have the same remarks that I had here https://github.com/HackYourAssignment/databases-cohort48/pull/37/files#r1760597771

@sarlam
Copy link

sarlam commented Sep 17, 2024

Thanks for updating your code :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants