-
-
Notifications
You must be signed in to change notification settings - Fork 516
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
Children served not calculated correctly if there are kits #4915
Comments
While looking into this I noticed another small issue with the calculations. For the calculation of We then use this sum to calculate the average monthly children served (converted to a float), so the Is this expected behavior? |
We probably should do a float division. |
@cielf I will make another PR for that. Double checking these calculations in this PR is already complicated enough imo |
@coalest Hrm. Yes. I don't care for the numbers that I'm currently getting for non-kitted diapers. All the "quantity per individual" is showing as blank for all, so with 12001 diapers, I would think I would get 240 total children served. I'm getting 235. So the float division is pretty important, actually -- Given the normal use, it's actually higher priority than getting the kits. right. But on with the kits... |
I can throw the floating point change into this PR if you prefer. |
I think what we want is to do the division as floating point, and then do a ceiling on that value -- at least for the total children served. A fractional child is a child for these purposes. Display total children helped as an integer. The average children helped -- displaying that as a float (maybe 2 decimals) would make sense. And yeah -- it will actually be easier, I think, to reason about this if we address the error in the 'loose' numbers. |
Summary
The children served number is not including children served with kits appropriately
Why fix?
Consistency. Corrextness.
Details
Regarding the Annual Survey
This method:
def children_served_with_kits_containing_disposables
organization
.distributions
.for_year(year)
.joins(line_items: {item: :kit})
.merge(Item.disposable)
.where.not(items: {kit_id: nil})
.distinct
.count("kits.id")
end
counts kits that are disposables (which will be 0), not kits that have disposables
Fix it.
(You probably shouldn't take this one unless you are familiar with both the annual survey and kits. And you might need to do SQL for this. So it's a little advanced)
Criteria for completion
The text was updated successfully, but these errors were encountered: