I’m not sure if its the best idea to create a background job that scans the database all the time for updated product prices, especially when in my application I expect to have 100,000s if not millions of products being observed for lower prices.
I have two models, Product and Price. a Product can have many different Prices. So the way I thought it should be done was:
- Subscribe to a Product.
- Create background job that scans database every hour for lower prices.
- Notify users by email.
I’m not sure about #2 and if that’s the best way for it to be done. What would you guys suggest?
If your Rails app is adding new Price objects to the Products in its database, why not have an ActiveRecord callback (
after_createin this instance) every time a new Price object is added?That ActiveRecord callback could start a delayed job to email the user about the new, lower price.