boulder-food-rescue / food-rescue-robot

A Rails App for Managing "Just in Time" Food Rescue, Developed by/for Boulder Food Rescue in Boulder, CO, USA
49 stars 56 forks source link

Shiftless Volunteers query perf + integration test #134

Closed brandonc closed 7 years ago

brandonc commented 7 years ago

Overview

Addresses #130 -- Previously, the shiftless volunteers route was loading all volunteers into memory and performing n2+1 database queries to figure out which ones in the shared regions have no shifts assigned. This was translated into equivalent SQL

Details

I thought a count subquery was simpler than an equivalent left join / group / having

Notes

There remains the question as to whether current_volunteer.region_ids is a decent criteria for finding shiftless volunteers. Another option might be current_volunteer.admin_region_ids ?

brandonc commented 7 years ago

Rebased and added a unit test for this query. To answer your question-- an assignment is the many-to-many record that relates volunteers to regions.

rylanb commented 7 years ago

Not confusing at all! I'd say an assignment is a shift! shakes head

brandonc commented 7 years ago

~Hang on somehow I may have broken features/shifts_needing_coverage_spec.rb~ nope it works

cllns commented 7 years ago

It's not very nice to call the volunteers shiftless, just because they don't have an assignment ;)

rylanb commented 7 years ago

They are adrift in the world, Sean!