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

Fix/api/marxan 479 fixed size calc #281

Merged
merged 4 commits into from
Jun 18, 2021
Merged

Conversation

aagm
Copy link
Member

@aagm aagm commented Jun 18, 2021

fix the calculation for min / max adding a conversion factor

@aagm aagm requested a review from hotzevzl June 18, 2021 10:29
@aagm aagm self-assigned this Jun 18, 2021
@vercel
Copy link

vercel bot commented Jun 18, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployments, click below or on the icon next to each commit.

marxan – ./app

🔍 Inspect: https://vercel.com/vizzuality1/marxan/F1PuWRw2kEVqZYj7o8Cjjpcrrv5Y
✅ Preview: https://marxan-git-fix-apimarxan-479fixed-size-calc-vizzuality1.vercel.app

marxan-storybook – ./app

🔍 Inspect: https://vercel.com/vizzuality1/marxan-storybook/39FfkcAhiVQr75LDvGXji7JLpLgF
✅ Preview: https://marxan-storybook-git-fix-apimarxan-479fixed-11ad70-vizzuality1.vercel.app

@aagm aagm added bug Something isn't working Ready to review PR ready to review API Everything related the api labels Jun 18, 2021
Copy link
Member

@hotzevzl hotzevzl left a comment

Choose a reason for hiding this comment

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

@aagm I am not sure about this approach - we are calculating the area via generated columns, and then basically overwriting these calculated numbers here, in ~70LOC vs... 2 if we did this in SQL? 🤔

Besides the LOC count which is not a real issue (most of it is repeated anyway), I find it also confusing to be recalculating some props in the extendResults hooks - since we can control what comes from these properties to start with, I would do that: extendResults in my opinion makes more sense for either reshaping or calculating data we don't have control over, or to add new properties, and so on.

also, what is the concept we are dealing with? in the db we calculate the area in m², here we calculate the length of the side of the square with that area, in km, but we use the same prop/name.

tl;dr - why not calculate both the m² area and the square side length (there should be a better name for this, but my neurons need lunch 😱), and adding these two new props to the entity and json:api serialization config?

@hotzevzl
Copy link
Member

tl;dr - why not calculate both the m² area and the square side length (there should be a better name for this, but my neurons need lunch scream), and adding these two new props to the entity and json:api serialization config?

⬆️ I meant calculating everything as generated columns

@aagm
Copy link
Member Author

aagm commented Jun 18, 2021

I was probably overengineering there and didn't want to touch the DB 🤦 but as you said it should be the best approach

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Everything related the api bug Something isn't working Ready to review PR ready to review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants