-
Notifications
You must be signed in to change notification settings - Fork 15
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: compact number in email should consider format #1656
Conversation
@gulfaraz so from 10% onwards it's rounded to tens of percentages? This is not what you said in the meeting, nor what Gal Said in the meeting right? |
@gulfaraz also, this is not correct in the new email |
@jannisvisser Thanks! Not much was said in the meeting. These changes are based on a review from weeks ago. I'll try to find some notes and update this PR. |
|
||
if (numberFormat === NumberFormat.perc) { | ||
// return average for percentage | ||
return total / triggeredAreas.length; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gulfaraz this is not fully correct. You have to take the weighted average, in this case through 'weightVar=total_houses', which is also an indicator-attribute. In aggregates.service in the front-end there is an example of how this is used. You can maybe argue this is already better than the sum we had before, but this will lead to differing numbers between email and portal. If too much work, you could yet again opt to omit the total (the whole line) in case of percentage. It's even arguable that this total percentage doesn't have much value, because it depends on how you go with including admin-areas in this set that are far from the track and have 1% damage, which is a semi-random rule anyway..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried and failed to understand the weighted var
and weighted average
so I fell back to a simple average. I want the email and portal values to match. The calculation on the frontend is coupled with place codes and layers so it's not easy to extract the underlying calculation.
Can you give a pseudo-code explanation of the correct calculation? I'm lost on which variables mean what and how they are connected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please realize that having this total figure in the email is a new feature, that is not currently not on production. So we're losing nothing with just omitting it.
Pseudocode formula is just something like: total-% = (area1-%*area1-total_houses + area2-%*area2-total_houses) / (area1-total_houses + area2-total_houses).
You probably don't have this additional data on 'total_houses' per area readily available at the place where you need it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please realize that having this total figure in the email is a new feature, that is not currently not on production. So we're losing nothing with just omitting it.
Noted.
Thank you @jannisvisser
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gulfaraz I see your new commit. To be honest I was actually meaning to only omit the line in the percentage case. Because it does work correctly in the sum-case, which is the vast majority of all implementations (population_affected). I guess you would maybe judge this unclean code and therefore prefer to remove it altogether? But in this particular case, it might be better to split it with a clear comment in the code explaining why.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest I was actually meaning to only omit the line in the percentage case.
This wasn't clear before and is now perplexing. Did the feature requirements describe this exception?
Because it does work correctly in the sum-case, which is the vast majority of all implementations (population_affected).
We agreed to have shared behaviour across countries and hazards without exceptions like these. I understand we implemented this feature before our agreement, but we're deciding to sign off on the feature now.
The requirement is to show the same aggregate value in the email as in the dashboard. If the suggestion is to show a value in the dashboard but not in the email, I advise to not ship a partial implementation. Let's refine this feature when it returns as feedback.
But in this particular case, it might be better to split it with a clear comment in the code explaining why.
This addresses the discrepancy for us devs. However, it does not explain why the value is missing to the end-user, those demoing IBF, design, and other stakeholders.
We have the opportunity to,
- Avoid the effort to document this exception
- Avoid communicating this exception to the relevant people mentioned above
- Avoid a future refactor to remove this exception
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'm convinced by your argumentation, but do not appreciate the unfriendly tone of the choice of the word 'perplexing' (unless I'm misinterpreting somehow).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By perplexing, I meant confusing. I apologize if it came across as unfriendly. It was very neutral.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, clear, thanks :)
The indicator value shown in the email event is incorrect. See review here and IBF Dev Chat for details.
The old indicator is wrong and there is no easy way to calculate the correct value without significant refactoring. So I removed the indicator following @jannisvisser's advice. After this change, the emails look like, |
Describe your changes
This PR is a result of feedback from @gal-agmon on #1515
Compact numbers in email consider number format. This changes PHL typhoon emails,
Before this PR, https://us18.campaign-archive.com/?u=e71f3b134823403aa6fe0c6dc&id=ce2d4c8cfb
After this PR, https://us18.campaign-archive.com/?u=e71f3b134823403aa6fe0c6dc&id=44951c89fb
Checklist before requesting a review