We did a quick patch in #4469 to unblock the release, but the code should be improved. It introduces some unwanted code duplication. The solution should hopefully also allow eager-loading of shipping rates in other parts of the app, see: https://github.com/openfoodfoundation/openfoodnetwork/pull/4469#discussion_r347828540
Code review in #4469
Hey @Matt-Yorkley this has been sitting in Dev Ready for eons, seemingly no activity since November last year. Can we either get it through to done or put it back in Dev Ready (or even decide if it's a priority anymore)?
I just had a quick look, but anything I do here seems to make the performance worse. It might be worth waiting until after #5030 is merged and before looking at it again.
Moving to tech debt backlog...
For future reference: the bullet gem says there are still N+1s here on shipping_method and address: state.
I think we can add something like this in order_decorator.rb once we get to Rails 4, and it should help with a lot of these issues around eager-loading shipping_method via order:
has_one :selected_shipping_rate, -> { where(selected: true) }, class_name: "Spree::ShippingRate"
Scopes in associations are not available in Rails 3...
ping @Matt-Yorkley I was cleaning up my "OFN notes" and bumped into this one.
Maybe it's now a good timing to have another look at this issue. Looks like something easy that can improve the overall performance of the app :+1:
Yeah, there's some great cleanup we can start doing now. :tada: This issue and #6282 are the same thing from two different viewpoints...