Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Agendamento
from __future__ import absolute_import
from celery import shared_task
# import the logging library
import logging
# Get an instance of a logger
logger = logging.getLogger(__name__)
@shared_task
def sendScheduledAlertTask(pk, scheduling_id):
from alerts.models import MaintenanceAlert
logger.info('entrei no task com pk igual a e tipo ' + str(pk) + str(type(pk)))
logger.info('tentei chegar no scheduling_id com ' + str(scheduling_id))
try:
alert = MaintenanceAlert.objects.get(pk=pk)
except MaintenanceAlert.DoesNotExist:
return
logger.info('entrei no task com o alerta %s' % alert.name)
if alert.status == MaintenanceAlert.SCHEDULED_TO_SEND and alert.scheduling_id == scheduling_id:
logger.info('entrei na atividade com o alerta %s' % alert.name)
alert.task_id = None
alert.scheduling_id = None
alert.save()
alert.send()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.