I encountered this issue as well.
In the process of fixing this, I also:
- Updated the order query so that it can be executed just once
- Fixed a loop on getSalesData that would run 14 * 86400 times more than needed
- Refactored getTopProducts so that it can use the new getOrders() function
- Added a few checks to ensure there will be no errors when getting top products
- Ordered top products by revenue and limited the result to top 20 (maybe this should be configurable in the future)
- Added a limit to return the top 40 most recent carts
- Updated the module dependencies
- Fixed an issue where numbers would show up with many decimal pointsHere is a proposed patch.