Question

I am not sure how things fit together ..

I have a app with active campaigns that anounce winners etc, and send out reminders for the campaigns. The campaign is created with django, and in the campaign model I have a field that says notify winners every X day or week or hour. So for this campaign, the winners must be announced every Friday. This is per campaign, there might be several campaigns with different winners and reminder settings.

Im not sure where to start the celerybeat task? Should it be on saving the model? But what if you change something and save the model again? Would it not create another task, then resulting in sending out 2 or more reminders etc?

Was it helpful?

Solution

Celerybeat is a daemon, it should run in the background permanently (with something like supervisord). Given the fact that your shortest reminder delay is an hour, it should run a task hourly.

This task should check all the campaigns, and decide according to the data from the data base which reminders it should send. To make things easier, I suggest that you calculate and save the next time a reminder should be sent when you send it. This way the next time, listing the reminders to be send will be as easy as listing all overdue reminders.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top