How to control schedule from web interface in code?
I have a quiz application where users can join a contest, with new questions each day. I want to make a interface where the client (admin) can control how many winners that should be drawn, and when they should be drawn.
For instance, client A may have 10 winners each friday from the last week, but client B wants 3 winners each day. How should I manage a user interface that talks with the Laravel scheduler?
The main issue I have, is how the interface should communicate with the scheduler, or in other words, how to "expose" the methods for the scheduler to a client in a nice interface?
Allow the user to create a schedule and the pre-populate all the draws in advance. Store these in a table and probably use the same to store the actual draw results.
create a cron job that runs eg every 15 minutes that collects all the draws that should have been run by this point. Then iterate over the draws and pick winners etc.
if the customer wants to vary the campaign then remove all future draws for that campaign and re create them to the new pattern.
This way you don't have to mess about trying to interact with the scheduler, plus you can catch up if the server is down for any length of time.
@Snapey Thanks for the tips! If a customer wants to have a drawing each day, do they manually have to enter each day to be drawn? Not sure how to work with date/time intervals.
Update: Seems like I can use rrule.js in frontend, and rrule.js inspired simshaun/recurr in backend, to generate each entry for drawing.