This is a spike on reports/orders&fulfilments to find potential improvements and potential quick wins that will improve performance on this page.
This report is one of our biggest pain points now.
Posting here some code to create orders in development. This works with the sample data created when running script/setup. This is collapsed below :point_down: - click on the heading to view.
Code to create orders in development
require "factory_bot_rails"
100.times do
distributor = (Enterprise.is_distributor.all + Enterprise.is_hub.all).sample
outgoing_exchange = Exchange.outgoing.where(receiver_id: distributor.id).all.sample
order_cycle = outgoing_exchange.order_cycle
variants = outgoing_exchange.variants
payment_method = distributor.payment_methods.where(type: "Spree::PaymentMethod::Check").all.sample
shipping_method = distributor.shipping_methods.all.sample
order = FactoryBot.create(:order, {
distributor: distributor,
order_cycle: order_cycle,
ship_address: FactoryBot.create(:address)
})
order.select_shipping_method(shipping_method)
order.save!
variants.each do |variant|
FactoryBot.create(:line_item, order: order, variant: variant)
end
order.create_proposed_shipments
FactoryBot.create(:payment, state: "checkout", order: order, amount: order.total,
payment_method: payment_method)
order.reload
order.update_distribution_charge!
order.reload
AdvanceOrderService.new(order).call!
end
Hey @kristinalim, just passed through this #2099 where @mkllnk did a spike on reports performance last year. Maybe there's some good info to take into account while working on this 馃憤
Thank you very much, @sigmundpetersen! I went through that issue just now - there are some interesting concepts there, and some others are no longer applicable. For now, I looked into making the DB queries for the Customer Totals report more optimized.
There are 4 report subtypes for the Orders and Fulfillments report. I am testing with 226 orders in my DB (development environment), and with my sample data got the following response times when generating the report without any filters:
As you can see, the Customer Totals report really needs more work than the others.
I created the following issues:
Many of these are small and easy changes.
This doesn't tackle bigger changes such as paginating, splitting, and emailing this report. There are more discussions about this in #2099. I think we should discuss and prioritize those separate from this spike.
Moving this epic to Code Review now. :tada:
That list of small issues looks great :+1:
nice work!!
I think we can close this spike 馃挭
(I have learnt the
I dont think these issues should be tagged bugs, I think it's better we keep a separate performance backlog with the performance tag.
I dont think these issues should be tagged bugs, I think it's better we keep a separate performance backlog with the performance tag.
@luisramos0 Yes actually, that sounds good to me! I'll remove the bug-s3 labels for now unless it's decided later to add the label.
@luisramos0 I thought you were making a joke, but later thought maybe you didn't realize it: :smile:
1:

2:

ahaha, I was just sharing that I didnt know about it but by using it in the sentence it created that funny effect :-)
And I just read this conversation via email and was surprised that the Details thing worked in my email program as well. :smile:
(3 year old Gnome Evolution)
Amazing job @kristinalim! this makes it super easy to have a constant stream of perf. improvements in each release :clap: :clap:
We can close this spike already. :+1:
Most helpful comment
And I just read this conversation via email and was surprised that the Details thing worked in my email program as well. :smile:
(3 year old Gnome Evolution)