Making thousands of API calls, taking forever
I'm building a Shopify app with Ruby on Rails, using the shopify_app gem. Currently, I'm looping through every single order in the past 30 days and then looping through each product inside of that order, in order to get data such as inventory count etc.. The goal is to get the amount of each product sold in the past 30 days along with their inventory count. I have a shop with over 5,000 orders in the past 30 days so the process takes forever. I have it running as a background job.
Is there a better way to do this? It's going to take hours the way I'm currently doing it.