Just about to start on a new section for an ongoing project, and just thought I would see what people think of this approach. It seems a bit "clunky" to me so was really just wondering whether anyone could suggest a more elegant method.
What I am trying to do: The site lets registered users create various "watch lists" to monitor for changes (sort of like a saved search). When new items are added to the website that match these criteria the users are emailed.
Couple of considerations : Users can sign up for many watch lists. Each user should receive a maximum of one email per day no matter how many of their watch lists have been added to.
My Plan: I currently have a table with each watch list occupying one row. This details the criteria that the user is watching for.
My plan is to have a nightly cron job that does the following:
- Get all the lists from the database, ordered by user
- Go to first watch-list
- Check the database for records added since last check
- If there are new records, create/add to email text
- Check if next watch-list is owned by same user. If yes, go back to step 3
- Mail user (using PHP mail function). Update "last checked" record
- Back to step 2
My question is really just whether this seems like a sensible approach. I am wondering how much load this could end up putting on the server if a few hundred users add a couple of lists each.
Any thoughts/feedback/suggestions would be appreciated.