mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-30 21:27:17 +00:00
When an incoming exchange of an order cycle changes, the ProductsCache queries all affected outgoing exchanges to update them. It was creating a big collection of exchanges with duplicates and then calling `uniq`. That call was hitting a custom implementation of `eql?` which is very inefficient. And since `Exchange.eql?` is ignoring the order cycle id, it was probably filtering too many exchanges from the collection. Fixed bug: If two order cycles sell exactly the same variants to the same shop, the two outgoing exchanges are seen as equal. When the variants change, ProductsCache would only update one of those two exchanges, leaving one order cycle out of sync. This case is very rare. It only happens if there is a shop with two active order cycles selling exactly the same. The new uniqueness test looks only at the attributes that are later used to refresh the cache. I measured a page speed improvement from 90 seconds to 3 seconds (30 times faster).