Add filters to distribution by county and take into account kitted items#5541
Add filters to distribution by county and take into account kitted items#5541cielf wants to merge 10 commits into
Conversation
… filters, restricting item filter to loose items only, added text re kitted items. Wondering about SQL portability from local to prod.
|
Couple of things right off the top: |
dorner
left a comment
There was a problem hiding this comment.
I've never been able to follow the logic with these complex reports. If it works I'll accept that it works. 😁 What did you mean by whether the SQL was "portable"?
| @reporting_categories = Item.reporting_categories_for_select | ||
| @items = current_organization.items.loose.alphabetized.select(:id, :name) | ||
| @selected_reporting_category = filter_params[:by_reporting_category].presence | ||
| @selected_item = filter_params[:by_item_id].presence |
There was a problem hiding this comment.
Can we bundle these into a view object? I'd like us to use more of these rather than relying on a bunch of instance variables.
There was a problem hiding this comment.
We use View::Donations.in donations#index.
There was a problem hiding this comment.
(nods) Ok - I see we have an example with Donations, so I'll see if I can apply that.
| ) | ||
| end | ||
|
|
||
| helper_method \ |
There was a problem hiding this comment.
Might be more readable if you just define the filter_params method and call helper_method :filter_params at the top.
| end | ||
| end | ||
| end | ||
| context "with kits only" do |
One of the things that has not stayed in my head is whether we are using postgres in production , and I know there are some differences between the SQL used by different relational dbs -- the element that might be of concern is the CASE construct . |
|
We're using postgres in production :) |
| .permit(:by_item_id, :by_reporting_category, :date_range) | ||
| end | ||
|
|
||
| def from_params(params:, organization:, helpers:) |
There was a problem hiding this comment.
Why do you need to pass helpers into this if you're including DateRangeHelpers?
All you need is a params method on the object. So you could do something like
def params = @params
def from_params(params:, organization:)
@params = params
filters = filter_params(params)
start_data = selected_range.first.utc.iso8601
...There was a problem hiding this comment.
@dorner Hrm -- I wonder how this case is different from the donations view object where you are passing helpers and has included DateRangeHelper?
I tried your suggestion and it broke most of the DistributionByCounty tests -- looking at the rspec log it doesn't know about selected_range at that point.
However, removing the DateRangeHelper include is harmless (the relevant tests still pass), so I've done that.
|
Good on my end - over to manual QA @janeewheatley @ruestitch |
|
@cielf Would you mind writing out some testing steps for QA for this one? Thank you! |
|
That kind of breaks the principle of having a different brain on the testing, but I understand that this is unfamiliar territory. |
|
This is going to be a bit hand-wavey, rather than setting out specific values -- and you'll likely be swearing in my general direction in any case by the time you are done! 1/ A/ Set up some partners -- 1 with no areas served, and 2 that have overlapping areas served. 2/ Check that the reporting by categories filters works without kits by adding some distributions for those partners with various items across reporting categories, then seeing that the numbers make sense both without filters and with. 3/ Now, checking that it works for kits -- add first a single distribution with one kit to the no areas served partner , then making sure it works with multiple kits in the same distribution, and that if you are distributing to the partners with areas served, that the values look right in that case -- i.e. that if you, say are distributing 20 kits that each have 10 tampons and 15 diapers, that you have 200 tampons and 300 diapers accounted for -- and that they are distributed properly across the areas served. A. Check without the reporting category filter. B. Check with the reporting category filter. 4/ Similarly to #3, but to a partner that has areas served. 5/ Now, do a really complicated case that has distributions to each of the partners, and those distributions have both kits and non-kitted items. Some of the non-kitted items are in the same reporting category as the kitted items, some aren't. A. Check without the reporting category filter. B. Check with the reporting category filter. 6/ Now that you're reallly quite familiar with the thing, think about whether I've forgotten anything, and test that. [Do you know for sure that it's not counting across organizations? Do the other filters (IIRC there s a date filter) still work? Is that what you're looking for? |
|
@janeewheatley 7/ Do the same tests for the items filter. |
Description
We've had a request to make the distribution by county more useful. This
Still to be done
Documentation update
Type of change
How Has This Been Tested?