Skip to content

Add filters to distribution by county and take into account kitted items#5541

Open
cielf wants to merge 9 commits intorubyforgood:mainfrom
cielf:add-filters-to-distribution-by-county
Open

Add filters to distribution by county and take into account kitted items#5541
cielf wants to merge 9 commits intorubyforgood:mainfrom
cielf:add-filters-to-distribution-by-county

Conversation

@cielf
Copy link
Copy Markdown
Collaborator

@cielf cielf commented Apr 21, 2026

Description

We've had a request to make the distribution by county more useful. This

  • allows for filtration by 'loose' item or reporting category as well as date range
  • includes kitted items into the item totals

Still to be done

Documentation update

Type of change

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • automated tests
  • light manual testing

cielf added 4 commits April 20, 2026 19:07
… filters, restricting item filter to loose items only, added text re kitted items. Wondering about SQL portability from local to prod.
@cielf cielf requested review from dorner and janeewheatley April 21, 2026 00:57
@cielf
Copy link
Copy Markdown
Collaborator Author

cielf commented Apr 21, 2026

Couple of things right off the top:
1/ This does require a documentation update, but I'd like to have @janeewheatley have a quick look at it before I go down the road of screenshots, etc.
2/ Is the SQL I did portable?

Copy link
Copy Markdown
Collaborator

@dorner dorner left a comment

Choose a reason for hiding this comment

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

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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We use View::Donations.in donations#index.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

(nods) Ok - I see we have an example with Donations, so I'll see if I can apply that.

)
end

helper_method \
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

spacing :)

@cielf
Copy link
Copy Markdown
Collaborator Author

cielf commented Apr 25, 2026

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"?

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 .

@dorner
Copy link
Copy Markdown
Collaborator

dorner commented Apr 27, 2026

We're using postgres in production :)

@cielf cielf marked this pull request as draft May 3, 2026 13:10
@cielf cielf marked this pull request as ready for review May 3, 2026 22:50
@cielf cielf requested a review from dorner May 3, 2026 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants