Hello everyone.
I’m creating a Django + Vue.js-based web application (specifically, using the Django REST Framework) designed for monitoring and controlling a robot. Users can schedule tasks following a repetition logic (Daily, weekly or monthly) and intervals (1,2…); For example, you want to perform a certain action with a daily repetition and an interval of 2, this means that the action will be executed every two days; In addition to that, in the model I determine the date range in which it will be carried out. (the model is the following)
class calendarios(models.Model):
nombre=models.CharField(max_length= 100, verbose_name='Nombre', unique=True)
acciones=models.ForeignKey(acciones, null=True,blank=True,on_delete=models.CASCADE,verbose_name='Acciones')
fecha_inicio = models.DateField(null=True, blank=True)
fecha_fin = models.DateField(null=True, blank=True)
repeticion= models.CharField(max_length=1, choices=repeticionChoices, default='D') # Ej: 'diaria', 'semanal', 'mensual'
intervalo = models.IntegerField(null=True, blank=True) # Número de días, semanas o meses dependiendo de la repeticion
todoCultivo= models.CharField(max_length=1, choices=SioNO, default='S')
hora_repeticion_1 = models.TimeField(null=True, blank=True) # Hora de la primera repetición diaria
hora_repeticion_2 = models.TimeField(null=True, blank=True) # Hora de la segunda repetición diaria
hora_repeticion_3 = models.TimeField(null=True, blank=True)
cultivo=models.ManyToManyField(cultivo, verbose_name="Cultivos",blank=True)
plantas=models.ManyToManyField(plantas, verbose_name="Plantas",blank=True)
def __str__(self):
return self.nombre
class Meta:
verbose_name = 'Calendario'
verbose_name_plural = 'Calendarios'
db_table = 'calendarios'
ordering = ['id']
Currently, I can store these tasks and also generate an array of events where the date, time and action to be performed are broken down based on the previous logic. Now, the problem is when executing since I do not know how to test or how to execute each activity present in the event array. I have no experience using Cron or Celery. How would I do this? The idea is that from time to time it is tested to know if some tasks need to be executed and that if the date and time coincide with the current one, it is carried out.
If you need more information to better understand what I’m looking for, please ask!
Thank you to everyone who will take the time to help me.