foodsoft icon indicating copy to clipboard operation
foodsoft copied to clipboard

Add sum column to order overview

Open kidhab opened this issue 2 years ago • 3 comments

Closes #822

kidhab avatar Oct 28 '22 15:10 kidhab

thanks for targeting that issue, but did you check the performance of your change?

the queries do not join on any of the required associated tables for the sum method, resulting in a IMO relevant N+1 problem if there are many orders

paroga avatar Oct 28 '22 16:10 paroga

I did test the performance only with the demo instance at foodcoops.net. What is a possible solution - to optimize the sum method?

kidhab avatar Oct 28 '22 21:10 kidhab

a good solution would be to calculate all the values directly via the database and change all usages of the sum. An easy solution would be to add all required required models with includes to the queries

BTW: you also missed to add the sum for the finished_orders, which are in the same table

paroga avatar Oct 29 '22 06:10 paroga